blob: 6bb159eadaa98445013615476fcde1501e73758d (
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
32
33
34
35
36
37
38
39
|
package beanstalk
import (
"github.com/beanstalkd/go-beanstalk"
)
func (j *consumer) listen() {
for {
select {
case <-j.stopCh:
j.log.Warn("beanstalk listener stopped")
return
default:
id, body, err := j.pool.Reserve(j.reserveTimeout)
if err != nil {
if errB, ok := err.(beanstalk.ConnError); ok {
switch errB.Err { //nolint:gocritic
case beanstalk.ErrTimeout:
j.log.Info("beanstalk reserve timeout", "warn", errB.Op)
continue
}
}
// in case of other error - continue
j.log.Error("beanstalk reserve", "error", err)
continue
}
item := &Item{}
err = j.unpack(id, body, item)
if err != nil {
j.log.Error("beanstalk unpack item", "error", err)
continue
}
// insert job into the priority queue
j.pq.Insert(item)
}
}
}
|