Mojo::...Method(3pm)

🌸 NAME 🌸

okay so bestie, this is the manual page for Mojo::...Method(3pm) β€” the User Contributed Perl Documentation one β€” and the actual class is Mojo::RabbitMQ::Client::Method. it is literally the generic class for all AMQP method calls. no cap, that’s the whole NAME section. πŸ’…


✨ SYNOPSIS ✨

here’s the group-chat demo, copy it exactly:

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;

πŸ¦‹ DESCRIPTION πŸ¦‹

Mojo::RabbitMQ::Client::Method is the general class for every AMQP method call. it’s giving β€œone wrapper to rule them all” energy, but for AMQP methods. πŸ’–


πŸŽ€ 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. so like, the reply you were waiting for pulls up, and this event says β€œhey bestie, we got it.” 🫢

message

Can be emitted by consumption & get methods.

empty

Can be emitted by get method, when no messages are available on queue. it’s the β€œinbox zero but make it AMQP” moment. πŸ“­βœ¨


πŸ’Ž ATTRIBUTES πŸ’Ž

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

is_sent

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

the ternary spells it out: "Method was sent" vs "Method is still pending delivery". very main character energy. πŸ‘‘

client

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

getter/setter cuteness for the client. πŸ’œ

name

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

getter/setter, and the example sets it to 'Basic::Get'. iconic. 🌟

arguments

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

getter/setter for the arguments hashref. the example is {no_ack => 1, ticket => 0, queue => 'amq.queue'}. πŸ“

expect

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

getter/setter for the expected replies. the example is [qw(Basic::GetOk Basic::GetEmpty)]. 🎯


πŸ”₯ 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. it’s the β€œlet’s get this method configured” step. πŸ’…

deliver

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

This delivers AMQP method call to server. Returns false when channel is not open, true otherwise. On successful delivery->reply cycle emits success event. error is emitted when none of expected replies are received. so yeah, ship it and watch the events do their thing. πŸš€


🌈 SEE ALSO 🌈

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


Copyright (C) 2015-2017, Sebastian Podjasek and others

Based on AnyEvent::RabbitMQ - Copyright (C) 2010 Masahito Ikuta, maintained by "bobtfish@bobtfish.net"

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.


and that’s the whole page, bestie. this manual was rendered by perl v5.42.0 on 2019-08-25. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from