Skip to content

Commit 11b9a83

Browse files
author
guilhermehubner
committed
Increse the heartbeat and fix middleware index
1 parent 9400ebb commit 11b9a83

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

broker/amqp.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ func (b *AMQPBroker) connect() {
215215
log.Get().Info("CONNECTING...")
216216

217217
for {
218-
connection, err := amqp.Dial(b.url)
218+
connection, err := amqp.DialConfig(b.url, amqp.Config{
219+
Heartbeat: 60 * time.Second,
220+
Locale: "en_US",
221+
})
222+
219223
if err != nil {
220224
log.Get().Error(fmt.Sprintf("broker/amqp: fail to connect: %v", err))
221225
time.Sleep(b.backoff.Duration())

worker.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ func (w *worker) executeJob() {
8787
index := i
8888
oldWrapped := wrappedHandle
8989

90-
wrappedHandle = func(ctx context.Context) error {
91-
return w.middlewares[index](injectJobInfo(ctx, *job, message),
92-
oldWrapped)
93-
}
90+
wrappedHandle = func(index int) func(context.Context) error {
91+
return func(ctx context.Context) error {
92+
return w.middlewares[index](injectJobInfo(ctx, *job, message),
93+
oldWrapped)
94+
}
95+
}(index)
9496
}
9597

9698
ctx, cancelFn := context.WithCancel(context.Background())

0 commit comments

Comments
 (0)