diff options
author | Valery Piashchynski <[email protected]> | 2021-08-31 17:20:33 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-08-31 17:20:33 +0300 |
commit | 0437d1f58514f694ea86e8176e621c009cd510f9 (patch) | |
tree | af0ea88580e852832d172e34b9698b1c87c98110 /plugins | |
parent | 83e7bc6afbc2e523a95cf9dcb8b25cf5f7ba3f1e (diff) | |
parent | 3ea498a1bf0dc29c8273b01417ff8d17ad5e97c3 (diff) |
#776: fix(amqp): type casting for the amqp headersv2.4.0-rc.1
#776: fix(amqp): type casting for the amqp headers
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/amqp/amqpjobs/item.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/amqp/amqpjobs/item.go b/plugins/amqp/amqpjobs/item.go index 66b70a36..04385afe 100644 --- a/plugins/amqp/amqpjobs/item.go +++ b/plugins/amqp/amqpjobs/item.go @@ -224,15 +224,25 @@ func (c *consumer) unpack(d amqp.Delivery) (*Item, error) { } } - if _, ok := d.Headers[job.RRDelay].(int64); ok { - item.Options.Delay = d.Headers[job.RRDelay].(int64) + if t, ok := d.Headers[job.RRDelay]; ok { + switch t.(type) { + case int, int16, int32, int64: + item.Options.Delay = t.(int64) + default: + c.log.Warn("unknown delay type", "want:", "int, int16, int32, int64", "actual", t) + } } - if _, ok := d.Headers[job.RRPriority]; !ok { + if t, ok := d.Headers[job.RRPriority]; !ok { // set pipe's priority item.Options.Priority = c.priority } else { - item.Options.Priority = d.Headers[job.RRPriority].(int64) + switch t.(type) { + case int, int16, int32, int64: + item.Options.Priority = t.(int64) + default: + c.log.Warn("unknown priority type", "want:", "int, int16, int32, int64", "actual", t) + } } return item, nil |