Skip to content

Commit

Permalink
Increse the heartbeat and fix middleware index
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermehubner committed Mar 7, 2018
1 parent 9400ebb commit 11b9a83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion broker/amqp.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ func (b *AMQPBroker) connect() {
log.Get().Info("CONNECTING...")

for {
connection, err := amqp.Dial(b.url)
connection, err := amqp.DialConfig(b.url, amqp.Config{
Heartbeat: 60 * time.Second,
Locale: "en_US",
})

if err != nil {
log.Get().Error(fmt.Sprintf("broker/amqp: fail to connect: %v", err))
time.Sleep(b.backoff.Duration())
Expand Down
10 changes: 6 additions & 4 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ func (w *worker) executeJob() {
index := i
oldWrapped := wrappedHandle

wrappedHandle = func(ctx context.Context) error {
return w.middlewares[index](injectJobInfo(ctx, *job, message),
oldWrapped)
}
wrappedHandle = func(index int) func(context.Context) error {
return func(ctx context.Context) error {
return w.middlewares[index](injectJobInfo(ctx, *job, message),
oldWrapped)
}
}(index)
}

ctx, cancelFn := context.WithCancel(context.Background())
Expand Down

0 comments on commit 11b9a83

Please sign in to comment.