Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare passive #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

steviebiddles
Copy link

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

* Update declarer interface with new passive methods
* Add DeclareQueuePassive
* Add DeclareExchangePassive
* Add tests for new methods
@kron4eg kron4eg self-requested a review February 12, 2017 15:40
@kron4eg
Copy link
Contributor

kron4eg commented Feb 13, 2017

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

Copy link
Contributor

@kron4eg kron4eg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to not break existing interfaces

@kron4eg
Copy link
Contributor

kron4eg commented Feb 14, 2017

@steviebiddles BTW, are you aware of this streadway/amqp#242 ?
Calling Declare passive methods will cause channel close in case if there is no target they checked for on broker.

@steviebiddles
Copy link
Author

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.

@kron4eg
Copy link
Contributor

kron4eg commented Feb 17, 2017

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

@steviebiddles
Copy link
Author

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?

@kron4eg
Copy link
Contributor

kron4eg commented Feb 28, 2017

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

* Add separate interface for passive methods
* Refactor passive methods and type assert to ensure they are similar types
@steviebiddles
Copy link
Author

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

Copy link
Author

@steviebiddles steviebiddles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes what you expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants