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

feat: Implemented the Retry and logging changes #49

Merged

Conversation

AkbaraliShaikh
Copy link
Member

@AkbaraliShaikh AkbaraliShaikh commented Oct 3, 2022

  1. Added simple retry logic on error
  2. Added the websocket client implementation
  3. Added implementation for standard logging output
  4. Providing the interface to the user to implement the choice of logging
  5. Refactored the names
  6. Updated the README document

// Do retries the function f, waits time between retries until a successful call is made.
// wait is time to wait for the next call
// maxAttempts is the maximum number if calls to the function.
func Do(wait time.Duration, maxAttempts uint, f func() error) error {
Copy link
Member

@ravisuhag ravisuhag Oct 10, 2022

Choose a reason for hiding this comment

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

@AkbaraliShaikh How will it handle OS interrupts? Shall we accept context and handle it?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ravisuhag Just trying to figure out why we need to handle OS signals here?
This is just a simple retry on any error.

Copy link
Member

Choose a reason for hiding this comment

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

I mean any service which uses this client how do they propagate context to cancel retry etc on the client users receive OS signal or other interrupts?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we want to give the client the option to cancel the ongoing request. Then, we must give the cancel context to the client APIs; this will require modification for all clients; should we address this in the current PR?

may take that up in the following because the PR is already too big to review now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Once an event is in flight, I don't see how we could stop sending it. Even if there was a way to kill the connection it still doesn't the purpose.
IMO: Having a cancel context is complex for the client and may be an overkill too for this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

@chakravarthyvp I agree to keep it simple.

Copy link
Member

@ravisuhag ravisuhag Nov 3, 2022

Choose a reason for hiding this comment

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

@chakravarthyvp It is not just about in-flight msg but we should also gracefully close the connections with the raccoon server and wait for ack etc on sent msgs.

Why do you think it will be hard for clients to pass context? They will simply pass the context while initiating the connection.

It is ok to enhance it in another PR but I think it will be important to do it.

Copy link
Contributor

@chakravarthyvp chakravarthyvp Nov 4, 2022

Choose a reason for hiding this comment

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

@ravisuhag
For graceful shutdown, I suppose handling interrupts or context may not be needed. We should let the client have fine grained control on when to close than with the raccoon-client taking this call. For this, We could provide a close() method at the interface where we can close the connection internally and the client can call this close() as part of their shutdown process. wdyt?

Sure, we can take this up in the next PR for further discussions on this.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that also sounds good.

@ravisuhag ravisuhag self-requested a review November 4, 2022 05:56
@chakravarthyvp chakravarthyvp merged commit 4cf098c into raystack:main Nov 4, 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.

3 participants