Skip to content

Commit

Permalink
fix: retry when connect to eventbus in sensor (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
exherb committed Aug 6, 2020
1 parent 5f7f16c commit 8a10287
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sensors/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/argoproj/argo-events/common/logging"
"github.com/argoproj/argo-events/eventbus"
eventbusdriver "github.com/argoproj/argo-events/eventbus/driver"
"github.com/argoproj/argo-events/eventsources/sources"
"github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
sensordependencies "github.com/argoproj/argo-events/sensors/dependencies"
sensortriggers "github.com/argoproj/argo-events/sensors/triggers"
Expand Down Expand Up @@ -102,9 +103,14 @@ func (sensorCtx *SensorContext) ListenEvents(ctx context.Context, stopCh <-chan
for _, t := range triggers {
triggerNames = append(triggerNames, t.Template.Name)
}
conn, err := ebDriver.Connect()
var conn eventbusdriver.Connection
err = sources.Connect(&common.DefaultRetry, func() error {
var err error
conn, err = ebDriver.Connect()
return err
})
if err != nil {
logger.Error("failed to connect to event bus", zap.Error(err))
logger.Fatal("failed to connect to event bus", zap.Error(err))
return
}
defer conn.Close()
Expand Down

0 comments on commit 8a10287

Please sign in to comment.