Mercury - Main broker application class
version 0.006
This is the main broker application class. With this class, you can add a message broker inside your Mojolicious application.
It is not necessary to use Mojolicious in order to use Mercury. For how to use Mercury to broker messages for any application, see the main Mercury documentation. For how to start the broker application, see the mercury broker command documentation or run mercury help broker.
mercury help broker
Establish a WebSocket message bus to send/recieve messages on the given topic. All clients connected to the topic will receive all messages published on the topic.
topic
This is a shorter way of doing both /pub/*topic and /sub/*topic, without the hierarchal message passing.
/pub/*topic
/sub/*topic
One difference is that by default a sender will not receive a message that they sent. To enable this behavior, pass a true value as the echo query parameter when establishing the websocket.
echo
$ua->websocket('/bus/foo?echo=1' => sub { ... });
Establish a WebSocket to subscribe to the given topic. Messages published to the topic or any child topics will be sent to this subscriber.
Establish a WebSocket to publish to the given topic. Messages published to the topic will be sent to all subscribers to the topic or any parent topics.
Establish a WebSocket to pull messages from the given topic. Messages will be routed in a round-robin fashion from pushers.
Establish a WebSocket to push messages to the given topic. Messages will be routed in a round-robin fashion to a single puller.
$c->add_bus_peer( $topic )
Add the current connection as a peer on the given bus topic. Connections can be joined to only one topic.
Remove the current connection from the given bus topic. Must be called to clean up the state.
$c->send_bus_message( $topic, $message )
Send a message to all the peers on the given bus. Will not send to the current peer (they should know what they sent).
$c->add_topic_subscriber( $topic );
Add the current connection as a subscriber to the given topic. Connections can be subscribed to only one topic, but they will receive all messages to child topics as well.
$c->remote_topic_subscriber( $topic );
Remove the current connection from the given topic. Must be called to clean up the state.
$c->publish_topic_message( $topic, $message );
Publish a message on the given topic. The message will be sent once to any subscriber of this topic or any child topics.
Doug Bell <preaction@cpan.org>
This software is copyright (c) 2015 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Mercury, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mercury
CPAN shell
perl -MCPAN -e shell install Mercury
For more information on module installation, please visit the detailed CPAN module installation guide.