Add custom exchange type and headers (#33)
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
This commit is contained in:
parent
db3f233aef
commit
8ade8eff40
|
|
@ -57,6 +57,33 @@ var _ = Describe("AMQP Exchange test ", func() {
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("AMQP Exchange Declare with Custom Exchange and Delete should succeed", func() {
|
||||||
|
var exchangeName = generateName("AMQP Exchange Declare with Custom Exchange and Delete should succeed")
|
||||||
|
|
||||||
|
exchangeInfo, err := management.DeclareExchange(context.TODO(), &CustomExchangeSpecification{
|
||||||
|
Name: exchangeName,
|
||||||
|
ExchangeTypeName: "x-local-random",
|
||||||
|
})
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(exchangeInfo).NotTo(BeNil())
|
||||||
|
Expect(exchangeInfo.Name()).To(Equal(exchangeName))
|
||||||
|
err = management.DeleteExchange(context.TODO(), exchangeName)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("AMQP Exchange Declare with Headers Exchange and Delete should succeed", func() {
|
||||||
|
var exchangeName = generateName("AMQP Exchange Declare with Headers Exchange and Delete should succeed")
|
||||||
|
|
||||||
|
exchangeInfo, err := management.DeclareExchange(context.TODO(), &HeadersExchangeSpecification{
|
||||||
|
Name: exchangeName,
|
||||||
|
})
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(exchangeInfo).NotTo(BeNil())
|
||||||
|
Expect(exchangeInfo.Name()).To(Equal(exchangeName))
|
||||||
|
err = management.DeleteExchange(context.TODO(), exchangeName)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
})
|
||||||
|
|
||||||
It("AMQP Exchange should fail when specification is nil", func() {
|
It("AMQP Exchange should fail when specification is nil", func() {
|
||||||
_, err := management.DeclareExchange(context.TODO(), nil)
|
_, err := management.DeclareExchange(context.TODO(), nil)
|
||||||
Expect(err).NotTo(BeNil())
|
Expect(err).NotTo(BeNil())
|
||||||
|
|
|
||||||
|
|
@ -330,9 +330,10 @@ func (s *StreamQueueSpecification) buildArguments() map[string]any {
|
||||||
type TExchangeType string
|
type TExchangeType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Direct TExchangeType = "direct"
|
Direct TExchangeType = "direct"
|
||||||
Topic TExchangeType = "topic"
|
Topic TExchangeType = "topic"
|
||||||
FanOut TExchangeType = "fanout"
|
FanOut TExchangeType = "fanout"
|
||||||
|
Headers TExchangeType = "headers"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ExchangeType struct {
|
type ExchangeType struct {
|
||||||
|
|
@ -414,6 +415,51 @@ func (f *FanOutExchangeSpecification) buildArguments() map[string]any {
|
||||||
return map[string]any{}
|
return map[string]any{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HeadersExchangeSpecification struct {
|
||||||
|
Name string
|
||||||
|
IsAutoDelete bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *HeadersExchangeSpecification) name() string {
|
||||||
|
return h.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *HeadersExchangeSpecification) isAutoDelete() bool {
|
||||||
|
return h.IsAutoDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *HeadersExchangeSpecification) exchangeType() ExchangeType {
|
||||||
|
return ExchangeType{Type: Headers}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *HeadersExchangeSpecification) buildArguments() map[string]any {
|
||||||
|
return map[string]any{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomExchangeSpecification struct {
|
||||||
|
Name string
|
||||||
|
IsAutoDelete bool
|
||||||
|
ExchangeTypeName string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CustomExchangeSpecification) name() string {
|
||||||
|
return c.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CustomExchangeSpecification) isAutoDelete() bool {
|
||||||
|
return c.IsAutoDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CustomExchangeSpecification) exchangeType() ExchangeType {
|
||||||
|
return ExchangeType{Type: TExchangeType(c.ExchangeTypeName)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CustomExchangeSpecification) buildArguments() map[string]any {
|
||||||
|
return map[string]any{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// / **** Binding ****
|
||||||
|
|
||||||
type BindingSpecification interface {
|
type BindingSpecification interface {
|
||||||
sourceExchange() string
|
sourceExchange() string
|
||||||
destination() string
|
destination() string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue