summaryrefslogtreecommitdiff
path: root/service/watchdog/watcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'service/watchdog/watcher.go')
-rw-r--r--service/watchdog/watcher.go50
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)
+
+ }
+}