Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions v1/brokers/amqp/amqp.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (b *Broker) StartConsuming(consumerTag string, concurrency int, taskProcess
false, // queue delete when unused
b.GetConfig().AMQP.BindingKey, // queue binding key
nil, // exchange declare args
nil, // queue declare args
amqp.Table(b.GetConfig().AMQP.QueueDeclareArgs), // queue declare args
amqp.Table(b.GetConfig().AMQP.QueueBindingArgs), // queue binding args
)
if err != nil {
Expand Down Expand Up @@ -210,7 +210,7 @@ func (b *Broker) Publish(ctx context.Context, signature *tasks.Signature) error
queue,
bindingKey, // queue binding key
nil, // exchange declare args
nil, // queue declare args
amqp.Table(b.GetConfig().AMQP.QueueDeclareArgs), // queue declare args
amqp.Table(b.GetConfig().AMQP.QueueBindingArgs), // queue binding args
)
if err != nil {
Expand All @@ -229,6 +229,7 @@ func (b *Broker) Publish(ctx context.Context, signature *tasks.Signature) error
Headers: amqp.Table(signature.Headers),
ContentType: "application/json",
Body: msg,
Priority: signature.Priority,
DeliveryMode: amqp.Persistent,
},
); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions v1/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ type Config struct {
// QueueBindingArgs arguments which are used when binding to the exchange
type QueueBindingArgs map[string]interface{}

// QueueDeclareArgs arguments which are used when declaring a queue
type QueueDeclareArgs map[string]interface{}

// AMQPConfig wraps RabbitMQ related configuration
type AMQPConfig struct {
Exchange string `yaml:"exchange" envconfig:"AMQP_EXCHANGE"`
ExchangeType string `yaml:"exchange_type" envconfig:"AMQP_EXCHANGE_TYPE"`
QueueDeclareArgs QueueDeclareArgs `yaml:"queue_declare_args" envconfig:"AMQP_QUEUE_DECLARE_ARGS"`
QueueBindingArgs QueueBindingArgs `yaml:"queue_binding_args" envconfig:"AMQP_QUEUE_BINDING_ARGS"`
BindingKey string `yaml:"binding_key" envconfig:"AMQP_BINDING_KEY"`
PrefetchCount int `yaml:"prefetch_count" envconfig:"AMQP_PREFETCH_COUNT"`
Expand Down
3 changes: 3 additions & 0 deletions v1/config/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ amqp:
exchange: exchange
exchange_type: exchange_type
prefetch_count: 123
queue_declare_args:
x-max-priority: 10
queue_binding_args:
image-type: png
x-match: any
Expand Down Expand Up @@ -55,6 +57,7 @@ func TestNewFromYaml(t *testing.T) {
assert.Equal(t, "exchange", cnf.AMQP.Exchange)
assert.Equal(t, "exchange_type", cnf.AMQP.ExchangeType)
assert.Equal(t, "binding_key", cnf.AMQP.BindingKey)
assert.Equal(t, 10, cnf.AMQP.QueueDeclareArgs["x-max-priority"])
assert.Equal(t, "any", cnf.AMQP.QueueBindingArgs["x-match"])
assert.Equal(t, "png", cnf.AMQP.QueueBindingArgs["image-type"])
assert.Equal(t, 123, cnf.AMQP.PrefetchCount)
Expand Down
2 changes: 2 additions & 0 deletions v1/config/testconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ amqp:
exchange: exchange
exchange_type: exchange_type
prefetch_count: 123
queue_declare_args:
x-max-priority: 10
queue_binding_args:
image-type: png
x-match: any
1 change: 1 addition & 0 deletions v1/tasks/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Signature struct {
GroupTaskCount int
Args []Arg
Headers Headers
Priority uint8
Immutable bool
RetryCount int
RetryTimeout int
Expand Down