Added RetryWithCallback allowing cb to terminate early with message#360
Added RetryWithCallback allowing cb to terminate early with message#360morganhein wants to merge 3 commits intogo-kit:masterfrom morganhein:retry_with_cb
Conversation
|
Your gofmt seems to be broken; it's inserting spaces instead of tabs? |
| // error message if desired. The error message may be nil, but a true/false | ||
| // is always expected. In all cases if the error message is supplied, the | ||
| // current error will be replaced. | ||
| type Callback func(int, string) (bool, *string) |
There was a problem hiding this comment.
Hmm, a pointer to a string is not a great way to encode maybe-error. It would make a lot more sense if Callback had the signature
type Callback func(n int, err error) (continue bool, err error)Is there a reason that's not possible?
There was a problem hiding this comment.
Yeah, I should've done that in the first place. Still learning obv. I'll fix spaces/tabs and the signature.
There was a problem hiding this comment.
I just gave this signature a try. I think the named return params help legibility, but continue is a keyword, so you'll probably have to go with cont.
|
Ping? :) |
|
I agree with @peterbourgon. Allowing the callback to receive an error would make it easier to handle the case described in #341, where you want to check for a particular error type. |
|
Looks like this has been abandoned. I'm closing in favor of #370, but please correct me if I've got it wrong :) Thanks for the initiative! :) |
#341
Love them callbacks.