Skip to content

Commit

Permalink
Rework HTTP device options
Browse files Browse the repository at this point in the history
  • Loading branch information
dshil committed Jan 24, 2025
1 parent 691f028 commit 945f0a9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions projects/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ type envContext struct {
cacheDir string
port int

deviceHTTP struct {
fetchTimeout string
fetchInterval string
device struct {
HTTP struct {
fetchTimeout string
fetchInterval string
}
}

mdns struct {
Expand Down Expand Up @@ -131,15 +133,15 @@ func (p *appPipeline) start(ec *envContext) error {
p.closer.Add("mdns-zeroconf-browser-runner", mdnsBrowserRunner)
p.starter.Add(mdnsBrowserRunner)

fetchInterval, err := time.ParseDuration(ec.deviceHTTP.fetchInterval)
fetchInterval, err := time.ParseDuration(ec.device.HTTP.fetchInterval)
if err != nil {
return err
}
if fetchInterval < time.Millisecond {
return errors.New("HTTP device fetch interval can't be less than 1ms")
}

fetchTimeout, err := time.ParseDuration(ec.deviceHTTP.fetchTimeout)
fetchTimeout, err := time.ParseDuration(ec.device.HTTP.fetchTimeout)
if err != nil {
return err
}
Expand Down Expand Up @@ -282,16 +284,14 @@ func main() {
"influxdb bucket")

cmd.Flags().StringVar(
&envContext.deviceHTTP.fetchInterval,
&envContext.device.HTTP.fetchInterval,
"device-http-fetch-interval", "5s",
"HTTP device data fetch interval, in form of: 1h35m10s12ms"+
" (valid time units are ms, s, m, h)",
"HTTP device data fetch interval",
)
cmd.Flags().StringVar(
&envContext.deviceHTTP.fetchTimeout,
&envContext.device.HTTP.fetchTimeout,
"device-http-fetch-timeout", "5s",
"HTTP device data fetch timeout, in form of: 1h35m10s12ms"+
" (valid time units are ms, s, m, h)",
"HTTP device data fetch timeout",
)

cmd.Flags().StringVar(
Expand Down

0 comments on commit 945f0a9

Please sign in to comment.