Skip to content
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

Enable RMQ messaging for Publisher in production #162

Closed
wants to merge 3 commits into from

Conversation

iainrb
Copy link

@iainrb iainrb commented Dec 11, 2017

  • Add PublisherFactory and PublisherWithMessaging classes, with tests
  • The PublisherFactory returns a PublisherWithMessaging if RabbitMQ is enabled; Publisher otherwise
  • RabbitMQ classes are imported at runtime using 'require'; allows running without RabbitMQ prerequisites installed
  • PublisherWithMessaging replaces PublisherMQTest
  • Shared RMQ test methods moved into TestRabbitMQ.pm
  • TODO Add parameters to explicitly enable/disable RabbitMQ instead of relying on the NPG_RMQ_CONFIG environment variable

@iainrb
Copy link
Author

iainrb commented Dec 12, 2017

Additions in commit 50ba359
PublisherFactory is now a Role, eg. to be consumed by Publisher classes in npg_irods. It has attributes:

  • enable_rmq
  • exchange (name of RabbitMQ exchange)
  • routing_key_prefix (for RabbitMQ routing key)


has 'exchange' =>
(is => 'ro',
isa => 'Maybe[Str]',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use predicates instread of MayBe see wtsi-npg/npg_irods#89

my $exchange_key = 'exchange';
my $prefix_key = 'routing_key_prefix';
my @rmq_keys = ($exchange_key, $prefix_key);
foreach my $key (@rmq_keys) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no need to check initargs this because Publisher uses MooseX::StrictConstructor. If you're accepting arguments to the factory method that need validating, it may be better to configure the factory to do the work and just allow some minimal positional parameters for the factory method itself.

use Moose;
use strict;
use warnings;
use Moose::Role;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changed to a role? These methods will now appear in the public API of anything that consumes them - do they need to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants