No way to pass secrets to KombuProducer
Closed this issue · 3 comments
According to docs (https://baseplate.readthedocs.io/en/stable/api/baseplate/clients/kombu.html?highlight=producer#example) I can configure KombuProducer in configure_context
like:
baseplate.configure_context(
app_config,
{
...
"ampq": KombuProducer(),
...
}
)
However right now the constructor doesn't accept secrets so it can't pass it to connection_from_config
so it won't work with any custom credentials (and can confusingly work with default ones)
I suggest adding secrets
parameter to KombuProducer
's __init__
in the same manner as SQLAlchemySession
has it.
Otherwise the workaround is manually initialize KombuProducerContextFactory and add it to the context.
connection = connection_from_config(app_config, prefix="amqp.", secrets=secrets)
exchange = exchange_from_config(app_config, prefix="amqp.")
baseplate.add_to_context("amqp", KombuProducerContextFactory(connection, exchange))
Ahh, good point.
If you'd like this addressed sooner, please feel free to open a PR and we can review it. I think this should be a pretty straight forward change, you could just add secrets
as an optional argument to the KombuProducer constructor (and add it as an attribute on the object) and then thread that into the connection_from_config call it makes in parse
.
Hey @pacejackson,
Sure. I've opened this PR: #451
#451 has been merged