File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 11package broker
22
33import (
4+ "log"
45 "time"
56
67 "github.com/kr/beanstalk"
@@ -60,10 +61,10 @@ func (bd *BrokerDispatcher) RunAllTubes() (err error) {
6061 }
6162
6263 go func () {
63- ticker := time . Tick (ListTubeDelay )
64+ ticker := instantTicker (ListTubeDelay )
6465 for _ = range ticker {
6566 if e := bd .watchNewTubes (); e != nil {
66- // ignore error
67+ log . Println ( e )
6768 }
6869 }
6970 }()
@@ -92,3 +93,16 @@ func (bd *BrokerDispatcher) watchNewTubes() (err error) {
9293
9394 return
9495}
96+
97+ // Like time.Tick() but also fires immediately.
98+ func instantTicker (t time.Duration ) <- chan time.Time {
99+ c := make (chan time.Time )
100+ ticker := time .NewTicker (t )
101+ go func () {
102+ c <- time .Now ()
103+ for t := range ticker .C {
104+ c <- t
105+ }
106+ }()
107+ return c
108+ }
You can’t perform that action at this time.
0 commit comments