logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Mojo::RabbitMQ::Client::Method - it's a generic class for all AMQP method calls

Attributes

       Mojo::RabbitMQ::Client::Method has following attributes.

   is_sent
         $method->is_sent ? "Method was sent" : "Method is still pending delivery";

   client
         my $client = $method->client;
         $method->client($client);

   name
         my $name = $method->name;
         $method->name('Basic::Get');

   arguments
         my $arguments = $method->arguments;
         $method->arguments({no_ack => 1, ticket => 0, queue => 'amq.queue'});

   expect
         my $expectations = $method->expect;
         $method->expect([qw(Basic::GetOk Basic::GetEmpty)]);

Description

       Mojo::RabbitMQ::Client::Method is general class for every AMQP method call.

Events

       Mojo::RabbitMQ::Client::Method inherits all events from Mojo::EventEmitter and can emit the following new
       ones.

   success
         $method->on(success => sub {
           my ($method, $frame) = @_;
           ...
         });

       Emitted when one of expected replies is received.

   message
       Can be emitted by consumption & get methods.

   empty
       Can be emitted by get method, when no messages are available on queue.

Methods

       Mojo::RabbitMQ::Client::Method inherits all methods from Mojo::EventEmitter and implements the following
       new ones.

   setup
         $method = $method->setup($name, $arguments, $expectations);

       Sets AMQP method name, its arguments and expected replies.

   deliver
         my $status = $method->deliver();

         This delivers AMQP method call to server. Returns C<<false>> when channel is not open, C<<true>> otherwise.
         On successful delivery->reply cycle emits C<<success>> event.
         C<<error>> is emitted when none of expected replies are received.

Name

       Mojo::RabbitMQ::Client::Method - it's a generic class for all AMQP method calls

See Also

       Mojo::RabbitMQ::Client::Channel, Mojo::RabbitMQ::Client

Synopsis

         use Mojo::RabbitMQ::Client::Method;

         my $method = Mojo::RabbitMQ::Client::Method->new(
           client => $client,
           channel => $channel
         )->setup(
           'Basic::Consume' => {
             ...
           },
           ['Basic::ConsumeOk', ...]
         );

         # Watch for errors
         $method->on(error => sub { warn "Error in reception: " . $_[1] });

         # Send this frame to AMQP
         $method->deliver;

See Also