Skip to content

Commit

Permalink
CLI: Add support for pollingInterval in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Cian911 committed Jan 14, 2022
1 parent ded17fc commit 113d879
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cli/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var (
// in yaml format
type Watchers struct {
// Watchers is a list of watchers
Watchers []Watcher `yaml:"watchers,mapstructure"`
Watchers []Watcher `yaml:"watchers,mapstructure"`
PollingInterval int `yaml:pollingInterval`
}

// Watcher is a struct that contains a path, destination, and file extention and event operation.
Expand Down Expand Up @@ -140,8 +141,14 @@ func registerMultiConsumers() {
pw.Register(&pc)
}

pi := viper.GetInt("poll")

if &ws.PollingInterval != nil {
pi = ws.PollingInterval
}

log.Println("Observing")
pw.Observe(viper.GetInt("poll"))
pw.Observe(pi)
}

func registerSingleConsumer() {
Expand Down
1 change: 1 addition & 0 deletions yaml/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pollingInterval: 120
watchers:
- path: "/Users/cian.gallagher/input"
destination: "/Users/cian.gallagher/output"
Expand Down

0 comments on commit 113d879

Please sign in to comment.