cony icon indicating copy to clipboard operation
cony copied to clipboard

Declare passive

Open steviebiddles opened this issue 8 years ago • 7 comments

  • 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 avatar Feb 11 '17 21:02 steviebiddles

@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.

kron4eg avatar Feb 13 '17 09:02 kron4eg

@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.

kron4eg avatar Feb 14 '17 13:02 kron4eg

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 avatar Feb 17 '17 19:02 steviebiddles

@steviebiddles yeah, just don't change exiting interface as I've pointed out previously.

kron4eg avatar Feb 17 '17 21:02 kron4eg

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 avatar Feb 18 '17 16:02 steviebiddles

@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.

kron4eg avatar Feb 28 '17 08:02 kron4eg

I added the interface and refactored the passive methods. The tests are passing without any changes to them.

steviebiddles avatar Mar 08 '17 22:03 steviebiddles