-
Notifications
You must be signed in to change notification settings - Fork 14
Support int16 and int64 in retries header #19
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
Conversation
It also rejects messages with malformed headers. Signed-off-by: Javi Fontan <[email protected]>
amqp/amqp.go
Outdated
| j.Retries = int32(r) | ||
|
|
||
| case int64: | ||
| j.Retries = int32(r) |
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.
it won't work! you'll have overflow issue (see: https://play.golang.org/p/-1sXpyO-KCY)
for in64 just do .retries.(int32) or modulo, or check if the value is < math.MaxInt32
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.
Retries in the job is an int32 so it cannot be bigger than that. This is done because the migration software converts all header integers to int64 but we don't expect them to be bigger that max_int32.
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.
I'll add the check just in case.
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.
ok, makes sense. you can also just in case do sth. like int32(r) & math.MaxInt32
Signed-off-by: Javi Fontan <[email protected]>
| return nil, ErrRetrievingHeader.New(DefaultConfiguration.RetriesHeader, d.MessageId) | ||
| } | ||
| switch r := retries.(type) { | ||
| case int16: |
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.
Why this case for int16?
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.
The three integer formats supported by amqp library are int16, int32 and int64. There for completeness. It says that supports int but returns error if it is used.
|
There's a problem with rabbitmq in windows. I've restarted the job in my appveyor account a couple of times and was not able to start the server (connect to the port). I'm merging as the changes should not be affecting windows. |
Some messages in borges returned the number of retries as an
int64number and this was generating errors.It also rejects messages with malformed headers. If not the messages will be unacked and eventually block the channel.