NAME
Mojolicious::Plugin::Pubsub - Pubsub plugin for Mojolicious
VERSION
version 0.001
SYNOPSIS
# Mojolicious
my $pubsub = $app->plugin('Pubsub', { cb => sub { print "Message: $_[0]\n"; }, socket => 'myapp.pubsub', });
$app->publish("message");
# Mojolicious::Lite
my $pubsub = plugin Pubsub => { cb => sub { print "Message: $_[0]\n"; }, socket => 'myapp.pubsub', };
app->publish("message");
DESCRIPTION
Easy way to add pubsub to your Mojolicious apps; it hooks into the Mojo::IOLoop to send and receive messages asynchronously.
NAME
Mojolicious::Plugin::Pubsub - Pubsub plugin for Mojolicious
OPTIONS
cb
Takes a callback CODE
reference. Specifying a callback in cb
is required, as that's the only recourse you have of getting a published message.
socket
A path to a UNIX
socket used to communicate between the publishers. By default this will be $app->moniker . '.pubsub'
.
HELPERS
publish
$c->publish("message");
Publishes a message that the callback will receive.
METHODS
register
my $pubsub = $plugin->register(Mojolicious->new, { cb => sub { ... }, socket => $path });
Register plugin in Mojolicious application.
SEE ALSO
AUTHOR
Andreas Guldstrand <andreas.guldstrand@gmail.com>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018 by Andreas Guldstrand.
This is free software, licensed under:
The MIT (X11) License