hutch
hutch copied to clipboard
Multiple `hosts` to Bunny
Right now the connection_params enforces a singular host
option for the Bunny connection. In an HA world we'd like this to be an array of rabbitmq hosts. Would you be open to allowing the uri
to have a comma separated host list, similar to how mongo handles clustering and instead pass hosts
to Bunny?
This would be a backwards compatible change.
@bradrobertson why not add :hosts
to it and pass it to Bunny? In fact, I think Hutch should expose all or at least all key connection-related options of Bunny.
Do you mean something like Hutch::Config[:mq_hosts]
? I'd be fine with that also. We'd just have to deal with the scenario of someone setting both as Bunny warns about that. Or we could just always pass in hosts
to Bunny and either use Hutch::Config[:mq_hosts]
or [ Hutch::Config[:mq_host] ]
. Thoughts?
@bradrobertson I'd just pass both to Bunny and let it do what's right. Hutch's job is to provide an opinionated set of conventions and a CLI daemon, not reinvent Bunny's features.
Ya I understand what you're saying, but from what I can tell, Hutch always passes in host
(if we use HUTCH_URI
which we do exclusively) and Bunny uses host
as a default (over hosts
) so passing both in means we'd never take advantage of multiple hosts.
Simply passing in hosts
instead gives us the best of both worlds.
@bradrobertson hm, and :host
takes precedence. It doesn't have to be that way, if :hosts
is set in the config we can assume the user wants it to be used. Using both options makes little sense.
Sure... Ok so the story is:
- Add a
Hutch::Config[:mq_hosts]
option, maps to the bunnyhosts
config option - Prefer
mq_hosts
overmq_host
if both are set
Questions:
- How do you want sanitized_uri dealt with. It seems to just be presentational, should it honour the same as above (prefer
hosts
overhost
) and maybe just comma separatehosts
in the uri string? - How does
mq_api_host
factor in here? I'm not actually sure what the api is used for in Hutch. Does it also need to support a rabbitmq cluster?
While Bunny supports its own ENV variable for URI connections IIRC (I have never advertised this feature and it was added for compatibility), Hutch's one is only managed by Hutch, so comma separating can be accomplished.
"mq_api_host" is RabbitMQ HTTP API. I suspect that Ruby HTTP API client used by Hutch. Hutch uses it to infer some information about the topology.
Err, by "can be accomplished" I mean "can be acceptable". I have no objections to that.
Any updates on this? It is possible to pass in a connection as a workaround but this idea seems reasonable to me.