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
20 changes: 10 additions & 10 deletions pkg/rabbitmqamqp/amqp_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ type AMQPBindingInfo struct {
}

type AMQPBinding struct {
sourceName string
destinationName string
toQueue bool
bindingKey string
management *AmqpManagement
additionalArguments map[string]any
sourceName string
destinationName string
toQueue bool
bindingKey string
management *AmqpManagement
arguments map[string]any
}

func newAMQPBinding(management *AmqpManagement) *AMQPBinding {
Expand All @@ -38,8 +38,8 @@ func (b *AMQPBinding) Destination(name string, isQueue bool) {
b.toQueue = isQueue
}

func (b *AMQPBinding) AdditionalArguments(args map[string]any) {
b.additionalArguments = args
func (b *AMQPBinding) Arguments(arguments map[string]any) {
b.arguments = arguments
}

// Bind creates a binding between an exchange and a queue or exchange
Expand All @@ -61,8 +61,8 @@ func (b *AMQPBinding) Bind(ctx context.Context) (string, error) {
kv["binding_key"] = b.bindingKey
kv["source"] = b.sourceName
kv[destination] = b.destinationName
if b.additionalArguments != nil {
kv["arguments"] = b.additionalArguments
if b.arguments != nil {
kv["arguments"] = b.arguments
} else {
kv["arguments"] = make(map[string]any)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/rabbitmqamqp/amqp_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var _ = Describe("AMQP Bindings test ", func() {
bindingPath, err := management.Bind(context.TODO(), &ExchangeToExchangeBindingSpecification{
SourceExchange: exchangeName,
DestinationExchange: exchangeName2,
Arguments: map[string]any{},
})

Expect(err).To(BeNil())
Expand All @@ -82,27 +83,31 @@ var _ = Describe("AMQP Bindings test ", func() {
_, err := management.Bind(context.TODO(), &ExchangeToExchangeBindingSpecification{
SourceExchange: "",
DestinationExchange: "destination",
Arguments: map[string]any{},
})
Expect(err).NotTo(BeNil())
Expect(err.Error()).To(ContainSubstring("source and destination names are required"))

_, err = management.Bind(context.TODO(), &ExchangeToExchangeBindingSpecification{
SourceExchange: "source",
DestinationExchange: "",
Arguments: map[string]any{},
})
Expect(err).NotTo(BeNil())
Expect(err.Error()).To(ContainSubstring("source and destination names are required"))

_, err = management.Bind(context.TODO(), &ExchangeToQueueBindingSpecification{
SourceExchange: "",
DestinationQueue: "destination",
Arguments: map[string]any{},
})
Expect(err).NotTo(BeNil())
Expect(err.Error()).To(ContainSubstring("source and destination names are required"))

_, err = management.Bind(context.TODO(), &ExchangeToQueueBindingSpecification{
SourceExchange: "source",
DestinationQueue: "",
Arguments: map[string]any{"binding_key": "key"},
})
Expect(err).NotTo(BeNil())
Expect(err.Error()).To(ContainSubstring("source and destination names are required"))
Expand Down
4 changes: 2 additions & 2 deletions pkg/rabbitmqamqp/amqp_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (a *AmqpManagement) DeclareQueue(ctx context.Context, specification IQueueS
amqpQueue.AutoDelete(specification.isAutoDelete())
amqpQueue.Exclusive(specification.isExclusive())
amqpQueue.QueueType(specification.queueType())
amqpQueue.SetArguments(specification.buildArguments())
amqpQueue.Arguments(specification.buildArguments())

return amqpQueue.Declare(ctx)
}
Expand Down Expand Up @@ -217,7 +217,7 @@ func (a *AmqpManagement) Bind(ctx context.Context, bindingSpecification IBinding
bind.SourceExchange(bindingSpecification.sourceExchange())
bind.Destination(bindingSpecification.destination(), bindingSpecification.isDestinationQueue())
bind.BindingKey(bindingSpecification.bindingKey())
bind.AdditionalArguments(bindingSpecification.arguments())
bind.Arguments(bindingSpecification.arguments())
return bind.Bind(ctx)

}
Expand Down
2 changes: 1 addition & 1 deletion pkg/rabbitmqamqp/amqp_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type AmqpQueue struct {
name string
}

func (a *AmqpQueue) SetArguments(arguments map[string]any) {
func (a *AmqpQueue) Arguments(arguments map[string]any) {
a.arguments = arguments
}

Expand Down
Loading