Add args to the exchanges (#34)
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
This commit is contained in:
parent
941ecfe6f6
commit
a0dbb5594d
|
|
@ -47,7 +47,9 @@ func (e *AmqpExchange) Declare(ctx context.Context) (*AmqpExchangeInfo, error) {
|
||||||
kv["auto_delete"] = e.isAutoDelete
|
kv["auto_delete"] = e.isAutoDelete
|
||||||
kv["durable"] = true
|
kv["durable"] = true
|
||||||
kv["type"] = e.exchangeType.String()
|
kv["type"] = e.exchangeType.String()
|
||||||
kv["arguments"] = e.arguments
|
if e.arguments != nil {
|
||||||
|
kv["arguments"] = e.arguments
|
||||||
|
}
|
||||||
_, err = e.management.Request(ctx, kv, path, commandPut, []int{responseCode204, responseCode201, responseCode409})
|
_, err = e.management.Request(ctx, kv, path, commandPut, []int{responseCode204, responseCode201, responseCode409})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ var _ = Describe("AMQP Exchange test ", func() {
|
||||||
const exchangeName = "AMQP Exchange Declare with FanOut and Delete should succeed"
|
const exchangeName = "AMQP Exchange Declare with FanOut and Delete should succeed"
|
||||||
exchangeInfo, err := management.DeclareExchange(context.TODO(), &FanOutExchangeSpecification{
|
exchangeInfo, err := management.DeclareExchange(context.TODO(), &FanOutExchangeSpecification{
|
||||||
Name: exchangeName,
|
Name: exchangeName,
|
||||||
|
Arguments: map[string]any{
|
||||||
|
"x-foo": "bar",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(exchangeInfo).NotTo(BeNil())
|
Expect(exchangeInfo).NotTo(BeNil())
|
||||||
|
|
@ -63,6 +66,9 @@ var _ = Describe("AMQP Exchange test ", func() {
|
||||||
exchangeInfo, err := management.DeclareExchange(context.TODO(), &CustomExchangeSpecification{
|
exchangeInfo, err := management.DeclareExchange(context.TODO(), &CustomExchangeSpecification{
|
||||||
Name: exchangeName,
|
Name: exchangeName,
|
||||||
ExchangeTypeName: "x-local-random",
|
ExchangeTypeName: "x-local-random",
|
||||||
|
Arguments: map[string]any{
|
||||||
|
"x-delayed-type": "direct",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(exchangeInfo).NotTo(BeNil())
|
Expect(exchangeInfo).NotTo(BeNil())
|
||||||
|
|
|
||||||
|
|
@ -349,12 +349,13 @@ type ExchangeSpecification interface {
|
||||||
name() string
|
name() string
|
||||||
isAutoDelete() bool
|
isAutoDelete() bool
|
||||||
exchangeType() ExchangeType
|
exchangeType() ExchangeType
|
||||||
buildArguments() map[string]any
|
arguments() map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
type DirectExchangeSpecification struct {
|
type DirectExchangeSpecification struct {
|
||||||
Name string
|
Name string
|
||||||
IsAutoDelete bool
|
IsAutoDelete bool
|
||||||
|
Arguments map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DirectExchangeSpecification) name() string {
|
func (d *DirectExchangeSpecification) name() string {
|
||||||
|
|
@ -369,13 +370,14 @@ func (d *DirectExchangeSpecification) exchangeType() ExchangeType {
|
||||||
return ExchangeType{Type: Direct}
|
return ExchangeType{Type: Direct}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DirectExchangeSpecification) buildArguments() map[string]any {
|
func (d *DirectExchangeSpecification) arguments() map[string]any {
|
||||||
return map[string]any{}
|
return d.Arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
type TopicExchangeSpecification struct {
|
type TopicExchangeSpecification struct {
|
||||||
Name string
|
Name string
|
||||||
IsAutoDelete bool
|
IsAutoDelete bool
|
||||||
|
Arguments map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TopicExchangeSpecification) name() string {
|
func (t *TopicExchangeSpecification) name() string {
|
||||||
|
|
@ -390,13 +392,14 @@ func (t *TopicExchangeSpecification) exchangeType() ExchangeType {
|
||||||
return ExchangeType{Type: Topic}
|
return ExchangeType{Type: Topic}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TopicExchangeSpecification) buildArguments() map[string]any {
|
func (t *TopicExchangeSpecification) arguments() map[string]any {
|
||||||
return map[string]any{}
|
return t.Arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
type FanOutExchangeSpecification struct {
|
type FanOutExchangeSpecification struct {
|
||||||
Name string
|
Name string
|
||||||
IsAutoDelete bool
|
IsAutoDelete bool
|
||||||
|
Arguments map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FanOutExchangeSpecification) name() string {
|
func (f *FanOutExchangeSpecification) name() string {
|
||||||
|
|
@ -411,13 +414,14 @@ func (f *FanOutExchangeSpecification) exchangeType() ExchangeType {
|
||||||
return ExchangeType{Type: FanOut}
|
return ExchangeType{Type: FanOut}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FanOutExchangeSpecification) buildArguments() map[string]any {
|
func (f *FanOutExchangeSpecification) arguments() map[string]any {
|
||||||
return map[string]any{}
|
return f.Arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
type HeadersExchangeSpecification struct {
|
type HeadersExchangeSpecification struct {
|
||||||
Name string
|
Name string
|
||||||
IsAutoDelete bool
|
IsAutoDelete bool
|
||||||
|
Arguments map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HeadersExchangeSpecification) name() string {
|
func (h *HeadersExchangeSpecification) name() string {
|
||||||
|
|
@ -432,14 +436,15 @@ func (h *HeadersExchangeSpecification) exchangeType() ExchangeType {
|
||||||
return ExchangeType{Type: Headers}
|
return ExchangeType{Type: Headers}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HeadersExchangeSpecification) buildArguments() map[string]any {
|
func (h *HeadersExchangeSpecification) arguments() map[string]any {
|
||||||
return map[string]any{}
|
return h.Arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomExchangeSpecification struct {
|
type CustomExchangeSpecification struct {
|
||||||
Name string
|
Name string
|
||||||
IsAutoDelete bool
|
IsAutoDelete bool
|
||||||
ExchangeTypeName string
|
ExchangeTypeName string
|
||||||
|
Arguments map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CustomExchangeSpecification) name() string {
|
func (c *CustomExchangeSpecification) name() string {
|
||||||
|
|
@ -454,8 +459,8 @@ func (c *CustomExchangeSpecification) exchangeType() ExchangeType {
|
||||||
return ExchangeType{Type: TExchangeType(c.ExchangeTypeName)}
|
return ExchangeType{Type: TExchangeType(c.ExchangeTypeName)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CustomExchangeSpecification) buildArguments() map[string]any {
|
func (c *CustomExchangeSpecification) arguments() map[string]any {
|
||||||
return map[string]any{}
|
return c.Arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
// / **** Binding ****
|
// / **** Binding ****
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue