How to config different amqp uris for different services


#1

From @alleriaken on Fri Mar 16 2018 02:35:57 GMT+0000 (UTC)

I want to set up my project so that each service will have a different amqp uri, is there anyway to do that?
here is my idea:
In config.yml:
DEFAULT_AMQP_URI: amqp://{RABBIT_USER:guest}:{RABBIT_PASSWORD:guest}@{RABBIT_HOST:localhost}:{RABBIT_PORT:5672}/

{SERVICE_1_NAME}_AMQP_URI: amqp://{RABBIT_USER_1:guest}:{RABBIT_PASSWORD_1:guest}@{RABBIT_HOST_1:localhost}:{RABBIT_PORT_1:5672}/

{SERVICE_2_NAME}_AMQP_URI: amqp://{RABBIT_USER_2:guest}:{RABBIT_PASSWORD_2:guest}@{RABBIT_HOST_2:localhost}:{RABBIT_PORT_2:5672}/

ect…

So that if a service that has config in config.yml will use its own uri, if not, it will use DEFAULT_AMQP_URI

or is there any way that I can set the amqp uri inside service file?

Thanks

Copied from original issue: https://github.com/nameko/nameko/issues/526


#2

From @mattbennett on Fri Mar 16 2018 13:45:50 GMT+0000 (UTC)

The way to do this is to use different config files for each service.

Changing the config key or value inside the service would take quite a lot of hacking because it’s not read in a single place. You can do it, but you’d have to subclass every AMQP extension that you’re using.