-
Notifications
You must be signed in to change notification settings - Fork 743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(eventbus): NATS eventbus auto reconnect and code refactory #749
Conversation
@@ -73,7 +71,16 @@ func NewNATSStreaming(url, clusterID, subject, clientID string, auth *Auth, logg | |||
|
|||
func (n *natsStreaming) Connect() (Connection, error) { | |||
log := n.logger.WithField("clientID", n.clientID) | |||
opts := []nats.Option{} | |||
opts := []nats.Option{ | |||
nats.MaxReconnects(-1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the significance of -1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1
means retry forever.
@@ -261,7 +286,7 @@ func (e *EventSourceAdaptor) Start(ctx context.Context, stopCh <-chan struct{}) | |||
return err | |||
} | |||
go func(s EventingServer) { | |||
err := s.StartListening(cctx, stopCh, func(data []byte) error { | |||
err := s.StartListening(cctx, func(data []byte) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can now remove // TODO: Need Retry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
()
in sensor dependency expression was trimmed when converting group expr to dependency expr.a. utilize NATS reconnect feature - for short term connection lost such as NATS POD crash
b. Extra Goroutins in eventsource and sensor service to auto reconnect - for long term connection lost
ctx.Done
instead ofstopCh