Skip to content
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

Merged
merged 4 commits into from
Jul 17, 2020

Conversation

whynowy
Copy link
Member

@whynowy whynowy commented Jul 16, 2020

  1. Fixed a bug that () in sensor dependency expression was trimmed when converting group expr to dependency expr.
  2. 2 layers of event bus auto reconnect:
    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
  3. Code refactory to use ctx.Done instead of stopCh

@@ -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),
Copy link
Contributor

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?

Copy link
Member Author

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 {
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@whynowy whynowy merged commit a8afcb7 into argoproj:master Jul 17, 2020
@whynowy whynowy deleted the bugfix branch July 17, 2020 15:36
juliev0 pushed a commit to juliev0/argo-events that referenced this pull request Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants