diff options
author | Wolfy-J <[email protected]> | 2019-05-02 22:47:51 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2019-05-02 22:47:51 +0300 |
commit | e3f8f80b40d55d9d3c2e858a73cc1befe3f04114 (patch) | |
tree | 958aed22ee91436d9302709f4364928fc66b98e5 /service | |
parent | b7637290225bf6fab2e41a55d9b9a6bd3f36142c (diff) |
symfony way to refernce contributors
Diffstat (limited to 'service')
-rw-r--r-- | service/watchdog/watcher.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/service/watchdog/watcher.go b/service/watchdog/watcher.go new file mode 100644 index 00000000..c8c4b3f2 --- /dev/null +++ b/service/watchdog/watcher.go @@ -0,0 +1,50 @@ +package watchdog + +import ( + "log" + "time" +) + +// disconnect?? +type Watcher struct { + // defines how often + interval time.Duration + pool Pool + + stop chan interface{} +} + +// NewWatcher creates new pool watcher. +func NewWatcher(p Pool, i time.Duration) *Watcher { + w := &Watcher{ + interval: i, + pool: p, + stop: make(chan interface{}), + } + + go func() { + ticker := time.NewTicker(w.interval) + + for { + select { + case <-ticker.C: + w.update() + case <-w.stop: + return + } + } + }() + + return w +} + +func (w *Watcher) Stop() { + close(w.stop) +} + +func (w *Watcher) update() { + for _, w := range w.pool.Workers() { + log.Println(w) + + } +} |