summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-05-02 22:47:51 +0300
committerWolfy-J <[email protected]>2019-05-02 22:47:51 +0300
commite3f8f80b40d55d9d3c2e858a73cc1befe3f04114 (patch)
tree958aed22ee91436d9302709f4364928fc66b98e5 /service
parentb7637290225bf6fab2e41a55d9b9a6bd3f36142c (diff)
symfony way to refernce contributors
Diffstat (limited to 'service')
-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)
+
+ }
+}