-
Notifications
You must be signed in to change notification settings - Fork 308
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
Support connection name #600
Support connection name #600
Conversation
@michaelklishin This is my first approach to solve this. Without the addition in docker-entrypoint, the CLI tool proceeded before the actual users were created, which resulted in countless Auth errors during testing. So this should enable more people to contribute here. I am eager to hear your feedback, especially whether the unit test is in the right place. I was not sure whether to put it rather into the integration/connection_spec... |
docker/docker-entrypoint.sh
Outdated
@@ -8,6 +8,7 @@ $server -detached | |||
|
|||
echo "Waiting for RabbitMQ to finish startup..." | |||
|
|||
sleep 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes no sense to sleep before rabbitmqctl await_startup
. That command waits for node boot to complete. User creation is synchronous, so I don't see any need to wait after we set up the permissions but at least it would make some sense there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, as an unrelated change, I'll remove this again. No problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can address this separately if needed. Admittedly I do not use this image for testing as I usually test Bunny against RabbitMQ nodes built from source or GA releases running locally.
lib/bunny/session.rb
Outdated
@@ -199,6 +201,7 @@ def initialize(connection_string_or_opts = ENV['RABBITMQ_URL'], optz = Hash.new) | |||
|
|||
client_props = opts[:properties] || opts[:client_properties] || {} | |||
@client_properties = DEFAULT_CLIENT_PROPERTIES.merge(client_props) | |||
@connection_name = @client_properties.fetch(:connection_name, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash#fetch
makes sense when you want a non-nil
default. Should we use Hash#[]
here?
This does not actually populate the client property by merging it into |
Ah now I think I know how you want to understand it: Instead of Bunny.new(properties: { connection_name: 'name' } } which will merge automatically to the @client_properties, you thought of something like this: @client_properties = DEFAULT_CLIENT_PROPERTIES.merge(client_props).merge(connection_name: opts[:connection_name])
=> Bunny.new(connection_name: 'name') Am I right? I like this even better. |
This is shown in the Management UI since rabbitmq/rabbitmq-management#172
245c73b
to
f027853
Compare
Correct, it should be easy to set a connection name, reading it is primarily useful for tests and, perhaps, logging.
|
Ok, I changed it to the easier usecase. What do you think? |
I have updated the code to support connection names specified directly in |
Thx for merging this so fastly. Will you make a new release soon? |
2.17.0 is up on rubygems.org. |
related to #599.