-
Notifications
You must be signed in to change notification settings - Fork 18
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: solver exponential backoff #450
base: main
Are you sure you want to change the base?
Conversation
const ( | ||
initialDelay = 1.0 | ||
maxAttempts = 10 | ||
exponential = 1.2 |
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.
nit: Could we rename this to exponent
?
errCh <- err | ||
select { | ||
case <-ctx.Done(): | ||
log.Info().Msg("Exiting readMessage loop due to context cancellation.") |
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.
log.Info().Msg("Exiting readMessage loop due to context cancellation.") | |
log.Debug().Msg("Exiting readMessage loop due to context cancellation.") |
This detail is a bit internal, would suggest dropping the log level to debug
.
continue | ||
switch { | ||
case websocket.IsCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure): | ||
log.Info().Msg("Solver service closed connection") |
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.
At the moment, we only use this helper function to connect to the solver. But we might re-use it in other contexts, so we may want to reword these errors to something like "Websocket server closed connection".
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.
Also, we may want to log errors we where we will attempt again at the warn
level.
switch { | ||
case websocket.IsCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure): | ||
log.Info().Msg("Solver service closed connection") | ||
return nil, fmt.Errorf("solver connection closed: %w", err) |
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.
Will returning here cause us to give up on our connection attempts?
Summary
This pull request makes the following changes:
ConnectWebSocket
to return an error alongside the response channelSolverClient
Task/Issue reference
Closes: #429
Test plan
pkg/http/websocket_server.go
to force an error inHandleFunc
:job-creator
terminal for exponential backoff logs