-
Notifications
You must be signed in to change notification settings - Fork 55
Upgrade backoff library to v5 #107
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ import ( | |||||||
| "io" | ||||||||
| "time" | ||||||||
|
|
||||||||
| "github.com/cenkalti/backoff/v4" | ||||||||
| "github.com/cenkalti/backoff/v5" | ||||||||
| "github.com/microsoft/durabletask-go/api" | ||||||||
| "github.com/microsoft/durabletask-go/backend" | ||||||||
| "github.com/microsoft/durabletask-go/internal/helpers" | ||||||||
|
|
@@ -90,23 +90,23 @@ func (c *TaskHubGrpcClient) StartWorkItemListener(ctx context.Context, r *task.T | |||||||
| return | ||||||||
| } | ||||||||
|
|
||||||||
| err = backoff.Retry( | ||||||||
| func() error { | ||||||||
| _, err = backoff.Retry[any](ctx, | ||||||||
| func() (any, error) { | ||||||||
| // user wants to stop the listener | ||||||||
| if ctx.Err() != nil { | ||||||||
| return backoff.Permanent(ctx.Err()) | ||||||||
| return nil, backoff.Permanent(ctx.Err()) | ||||||||
| } | ||||||||
|
|
||||||||
| c.logger.Infof("reconnecting work item listener stream") | ||||||||
| streamErr := initStream() | ||||||||
| if streamErr != nil { | ||||||||
| c.logger.Errorf("error initializing work item listener stream %v", streamErr) | ||||||||
| return streamErr | ||||||||
| return nil, streamErr | ||||||||
| } | ||||||||
| return nil | ||||||||
| return nil, nil | ||||||||
| }, | ||||||||
| // retry forever since we don't have a way of asynchronously return errors to the user | ||||||||
| newInfiniteRetries(), | ||||||||
| backoff.WithBackOff(newInfiniteRetries()), | ||||||||
| ) | ||||||||
| if err != nil { | ||||||||
| c.logger.Infof("stopping background processor, unable to reconnect stream: %v", err) | ||||||||
|
|
@@ -205,8 +205,6 @@ func newInfiniteRetries() *backoff.ExponentialBackOff { | |||||||
| b := backoff.NewExponentialBackOff() | ||||||||
| // max wait of 15 seconds between retries | ||||||||
| b.MaxInterval = 15 * time.Second | ||||||||
|
||||||||
| b.MaxInterval = 15 * time.Second | |
| b.MaxInterval = 15 * time.Second | |
| b.MaxElapsedTime = 0 // infinite retries |
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.
No, this has been moved to Retry. There is no max elapsed time tracking in the backoff setting anymore.
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.
Seems to me this could be rewriten to use backoff.Retry as well.
The only difference: the backoff library doesn't start by waiting for a tick.