break: retry: simplify API (remove ClassifierFn, change WorkFn)#17
Merged
marco-m-pix4d merged 5 commits intomasterfrom Apr 14, 2026
Merged
break: retry: simplify API (remove ClassifierFn, change WorkFn)#17marco-m-pix4d merged 5 commits intomasterfrom
marco-m-pix4d merged 5 commits intomasterfrom
Conversation
Cogito is using two HTTP APIs: GitHub And Google Chat. The GitHub API was wrapped with go-kit/retry since a long time ago, while the Google Chat API was wrapped with go-kit/retry only last week in Pix4D/cogito#177. While working on the wrapping of the Google Chat API, I realized that go-kit/retry was clumsy to use. Thus this PR. Old API: ```go func (rtr Retry) Do( backoffFn BackoffFunc, classifierFn ClassifierFunc, // <== will be removed workFn WorkFunc, ) error type ClassifierFunc func(err error) Action // <== will be removed type WorkFunc func() error // <== will change return signature ``` New API: ```go func (rtr Retry) Do( backoffFn BackoffFunc, workFn WorkFunc, ) error type WorkFunc func() (Action, error) ``` Realization: There is no need for function `ClassifierFn`, since `WorkFn` has already all the information and putting the logic to decide the retry closer to the work makes it easier to understand what is going on.
Same approach as googlechat.DefaultRetry()
odormond
approved these changes
Apr 14, 2026
SpectreVert
approved these changes
Apr 14, 2026
iAmoric
approved these changes
Apr 14, 2026
Member
|
We're missing
And last thing: Line 2 in a1a7cf4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Cogito is using two HTTP APIs: GitHub And Google Chat.
The GitHub API was wrapped with go-kit/retry since a long time ago, while the Google Chat API was wrapped with go-kit/retry only last week in Pix4D/cogito#177.
While working on the wrapping of the Google Chat API, I realized that go-kit/retry was clumsy to use. Thus this PR.
Old API:
New API:
Realization:
There is no need for function
ClassifierFn, sinceWorkFnhas already all the informationand putting the logic to decide the retry closer to the work makes it easier
to understand what is going on.