blob: e1922517b103330f305d168b356bbcb62b76f159 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package beanstalk
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()
}
}
|