Skip to content

Commit

Permalink
Temp workaround for #128
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencegripper committed Jul 2, 2018
1 parent 4112de8 commit 19c21fa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/app/frontapi/links/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package links

import (
"context"
"time"

"github.com/lawrencegripper/ion/internal/pkg/servicebus"
log "github.com/sirupsen/logrus"
"pack.ag/amqp"

"github.com/lawrencegripper/ion/internal/pkg/types"
Expand All @@ -24,6 +26,23 @@ func InitAmqp(cfg *types.Configuration, eventToSend string) {
panic(err)
}
amqpSender = newSender
// workaround for issue: https://github.com/lawrencegripper/ion/issues/128
go func() {
for {
time.Sleep(time.Duration(time.Minute * 9))
contextDeadline, cancel := context.WithTimeout(context.Background(), time.Duration(time.Second*2))
defer cancel()
err := newSender.Close(contextDeadline)
if err != nil {
log.WithError(err).Error("failed to close connection to renew link")
}
newSender, err := amqpClt.CreateAmqpSender(eventToSend)
if err != nil {
log.WithError(err).Panic("failed to estabilish connection to amqp")
}
amqpSender = newSender
}
}()
}

type request struct {
Expand Down

0 comments on commit 19c21fa

Please sign in to comment.