summaryrefslogtreecommitdiff
path: root/plugins/jobs/drivers/beanstalk/redial.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jobs/drivers/beanstalk/redial.go')
-rw-r--r--plugins/jobs/drivers/beanstalk/redial.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/plugins/jobs/drivers/beanstalk/redial.go b/plugins/jobs/drivers/beanstalk/redial.go
index c9e72ad8..e1922517 100644
--- a/plugins/jobs/drivers/beanstalk/redial.go
+++ b/plugins/jobs/drivers/beanstalk/redial.go
@@ -1,3 +1,31 @@
package beanstalk
-func (j *JobConsumer) redial() {}
+import (
+ "sync/atomic"
+
+ "github.com/beanstalkd/go-beanstalk"
+)
+
+func (j *JobConsumer) redial() {
+ for range j.reconnectCh {
+ // backoff here
+
+ j.Lock()
+
+ var err error
+ j.conn, err = beanstalk.DialTimeout(j.network, j.addr, j.tout)
+ if err != nil {
+ panic(err)
+ }
+
+ j.tube = beanstalk.NewTube(j.conn, j.tName)
+ j.tubeSet = beanstalk.NewTubeSet(j.conn, j.tName)
+
+ // restart listener
+ if atomic.LoadUint32(&j.listeners) == 1 {
+ go j.listen()
+ }
+
+ j.Unlock()
+ }
+}