Files
ddns-updater-qdm12-3/internal/config/client.go
2024-01-19 11:42:48 +00:00

42 lines
745 B
Go

package config
import (
"time"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/reader"
"github.com/qdm12/gotree"
)
type Client struct {
Timeout time.Duration
}
func (c *Client) setDefaults() {
const defaultTimeout = 20 * time.Second
c.Timeout = gosettings.DefaultComparable(c.Timeout, defaultTimeout)
}
func (c Client) Validate() (err error) {
return nil
}
func (c Client) String() string {
return c.toLinesNode().String()
}
func (c Client) toLinesNode() *gotree.Node {
node := gotree.New("HTTP client")
node.Appendf("Timeout: %s", c.Timeout)
return node
}
func (c *Client) read(reader *reader.Reader) (err error) {
c.Timeout, err = reader.Duration("HTTP_TIMEOUT")
if err != nil {
return err
}
return nil
}