Skip to content

Commit

Permalink
fix(leaderelection): never give up connection retry to nats server (#…
Browse files Browse the repository at this point in the history
…1748)

* fix(leaderelection): never give up connection retry to nats server

Signed-off-by: Derek Wang <whynowy@gmail.com>

* .

Signed-off-by: Derek Wang <whynowy@gmail.com>

* .

Signed-off-by: Derek Wang <whynowy@gmail.com>
  • Loading branch information
whynowy authored Mar 23, 2022
1 parent c633ab1 commit 9e9e90b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 4 additions & 5 deletions common/leaderelection/leaderelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ func NewEventBusElector(ctx context.Context, eventBusConfig eventbusv1alpha1.Bus
}
v.WatchConfig()
v.OnConfigChange(func(e fsnotify.Event) {
logger.Info("eventbus auth config file changed.")
err = v.Unmarshal(cred)
if err != nil {
logger.Errorw("failed to unmarshal auth.yaml after reloading", zap.Error(err))
}
// Auth file changed, let it restart.
logger.Fatal("Eventbus auth config file changed, exiting..")
})
auth = &eventbusdriver.Auth{
Strategy: *eventBusAuth,
Expand Down Expand Up @@ -95,6 +92,8 @@ func (e *natsEventBusElector) RunOrDie(ctx context.Context, callbacks LeaderCall
log := logging.FromContext(ctx)
ci := graft.ClusterInfo{Name: e.clusterName, Size: e.size}
opts := &nats.DefaultOptions
// Will never give up
opts.MaxReconnect = -1
opts.Url = e.url
if e.auth.Strategy == eventbusv1alpha1.AuthStrategyToken {
opts.Token = e.auth.Crendential.Token
Expand Down
7 changes: 2 additions & 5 deletions eventbus/eventbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ func GetDriver(ctx context.Context, eventBusConfig eventbusv1alpha1.BusConfig, s
}
v.WatchConfig()
v.OnConfigChange(func(e fsnotify.Event) {
logger.Info("eventbus auth config file changed.")
err = v.Unmarshal(cred)
if err != nil {
logger.Errorw("failed to unmarshal auth.yaml after reloading", zap.Error(err))
}
// Auth file changed, let it restart
logger.Fatal("Eventbus auth config file changed, exiting..")
})
auth = &driver.Auth{
Strategy: *eventBusAuth,
Expand Down

0 comments on commit 9e9e90b

Please sign in to comment.