inway / mojo-rabbitmq-client

Mojo::IOLoop based RabbitMQ (AMQP) client
Artistic License 2.0
15 stars 17 forks source link

Publisher API #5

Closed tyldum closed 6 years ago

tyldum commented 7 years ago

AFAICS, the routing key is derived from the ?queue query-param. This means you need one publisher per routing key, while my design has a very dynamic routing key that is unlikely to repeat more than a few times per week.

I would like to introduce the routing key to publish(). I can create a PR, but I was debating with myself over semantics:

->publish('body',\%headers,'routing_key') vs ->publish('body', { headers => \%headers, routing_key => 'some.routing.key' }) The second one opens up for more flexibility for other options needed.

SPodjasek commented 7 years ago

I'll opt for following signature:

publish($body!, \%headers?, *@params)

which will allow to call it like this:

->publish($body, { header => 'value' }, routing_key => 'something', 
                                        mandatory => 1, immediate => 0);
->publish($body, routing_key => 'something');
->publish($body, { header => 'value' });
->publish($body);

With following rules:

What do you think?

tyldum commented 7 years ago

I'm fine with that! Do you want a PR with that or would you prefer to do it yourself?

SPodjasek commented 7 years ago

If you can, please write a PR - I don't have much spare time lately

kraih commented 6 years ago

@tyldum Just make it flexible.

SPodjasek commented 6 years ago

In a5e148fc9c24a3612c6d37cf5d34dc1845200f62 I've changed publisher code to use ?routing_key= query parameter instead of ?queue=

SPodjasek commented 6 years ago

Resolved in 5a7cf91