cony
cony copied to clipboard
Declare passive
- Update declarer interface with new passive methods
- Add DeclareQueuePassive
- Add DeclareExchangePassive
- Add tests for new methods
Allow users to test for the existence of a queue.
@steviebiddles I would rather not change existing interface. But instead added new functions in func Declare*
family (DeclareQueuePassive). And type assert inside them if passed in Declarer
interface is implementing those *Passive
methods.
@steviebiddles BTW, are you aware of this https://github.com/streadway/amqp/issues/242 ?
Calling Declare passive
methods will cause channel close in case if there is no target they checked for on broker.
Thanks for the update. I was not aware of that but if that is the way the protocol works it should be ok to make the changes.
@steviebiddles yeah, just don't change exiting interface as I've pointed out previously.
I am new to Go and I have been trying to implement the *Passive
methods without making changes to the existing interface. I created a new interface DeclarerPassive
and i'm trying the type assert inside the new methods that implement the new interface.
//...
return func(c Declarer) error {
cp, found := c.(DeclarerPassive)
if !found {
return errors.New("Type not found.")
}
//...
When I debug and step over I see that c
and cp
are the type I expect but found
is always false.
Is this the change you recommended?
@steviebiddles you need to design your DeclarerPassive interface with two methods https://godoc.org/github.com/streadway/amqp#Channel.ExchangeDeclarePassive and https://godoc.org/github.com/streadway/amqp#Channel.QueueDeclarePassive (just method signatures) You see found == false because you run those in tests. In production program https://godoc.org/github.com/streadway/amqp#Channel will be passed inside as Declarer and thus it will satisfy your DeclarerPassive.
I added the interface and refactored the passive methods. The tests are passing without any changes to them.