-
Notifications
You must be signed in to change notification settings - Fork 136
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
add methods Temporary and Recoverable to amqp.Error #265
add methods Temporary and Recoverable to amqp.Error #265
Conversation
Hey, thank you for taking the time to contribute this PR. I like the proposal and the code looks good. There's a test failure that seems related to the change on this PR, the test breaking is error.log
I'm happy to merge after all tests become green. IIRC this is an integration test, you will need a running rabbit to run the suite. |
hello @Zerpet I start a local rabbitmq using docker and I run only this test on both main branch and my branch add-method... and I got similar results:
I don't think my patch had any impact on it |
I add some small changes in other aspects of the code and tests (fix lint issues, etc) If needed I can cherry pick and submit another PR |
I had another look at the error, and I agree, your patch doesn't seem to be the root cause. In fact, it seems specific to GitHub actions, and the fact that it runs on low CPU specs, and IIRC no more than 2-cores.
Thank you for your additional work on this client, much appreciated! I'll take the offer and kindly ask you to open a different PR with the code formatting and linter fixes. I'll be happy to merge both PRs when ready. |
Sure, I will prepare a second PR right now |
f8f6669
to
3e232fa
Compare
@Zerpet done |
and the other commits I move to #266 |
Waiting for CI to pass before merging |
Today if I need to check if the error from amqp library is retriable or not, I need to try convert from
error
to*amqp.Error
and check fields such asCode
orRecover
viaerrors.As
function (because the error can be wrapped).However, I may have other kinds of error such context deadline, etc,
A better way is to follow some common interface like
Timeout() bool
orTemporary() bool
I choose the second one for amqp.Error -- I hope you will like it
Temporary interface returns true for two specific error codes:
I choose this two error codes based on this disclaimer https://github.com/google/go-cloud/blob/e0e5901b220191edf32c42cabd87f799858830a0/pubsub/rabbitpubsub/rabbit.go#L497
Since this definition is very restrictive, I add a more simple method:
Recoverable() bool
thar returns the content of the fieldRecover
All temporary errors are recoverable, but not all recoverable errors are temporary. If an error code requires outside action it is not temporary in the sense of redoing the same action will end in the same error code, until something else is done.
If such definitions does not help, lets discuss a better solution.
BTW I just add a
GoString
method to return all field values when used the%#v
optionRegards