AnyEvent-Stomper
view release on metacpan or search on metacpan
lib/AnyEvent/Stomper/Cluster.pm view on Meta::CPAN
=head2 new( %params )
my $cluster = AnyEvent::Stomper::Cluster->new(
nodes => [
{ host => 'stomp-server-1.com', port => 61613 },
{ host => 'stomp-server-2.com', port => 61613 },
{ host => 'stomp-server-3.com', port => 61613 },
],
login => 'guest',
passcode => 'guest',
vhost => '/',
heartbeat => [ 5000, 5000 ],
connection_timeout => 5,
reconnect_interval => 5,
on_node_connect => sub {
my $host = shift;
my $port = shift;
# handling...
},
on_node_disconnect => sub {
my $host = shift;
my $port = shift;
# handling...
},
on_node_error => sub {
my $err = shift;
my $host = shift;
my $port = shift;
# error handling...
},
on_error => sub {
my $err = shift;
# error handling...
},
);
=over
=item nodes => \@nodes
Specifies the list of nodes. Parameter should contain array of hashes. Each
hash should contain C<host> and C<port> elements. At the start the client gets
random node from this list, connects to it and sends all frames to this node.
If current active node fails, the client gets next node from the list.
=item login => $login
The user identifier used to authenticate against a secured STOMP server. Must
be the same for all nodes.
=item passcode => $passcode
The password used to authenticate against a secured STOMP server. Must be the
same for all nodes.
=item vhost => $vhost
The name of a virtual host that the client wishes to connect to. Must be the
same for all nodes.
=item heartbeat => \@heartbeat
Heart-beating can optionally be used to test the healthiness of the underlying
TCP connection and to make sure that the remote end is alive and kicking. The
first number sets interval in milliseconds between outgoing heart-beats to the
node. C<0> means, that the client will not send heart-beats. The second number
sets interval in milliseconds between incoming heart-beats from the node. C<0>
means, that the client does not want to receive heart-beats.
heartbeat => [ 5000, 5000 ],
Not set by default.
=item connection_timeout => $connection_timeout
Specifies connection timeout. If the client could not connect to the node
after specified timeout, the C<on_node_error> callback is called with the
C<E_CANT_CONN> error. The timeout specifies in seconds and can contain a
fractional part.
connection_timeout => 10.5,
By default the client use kernel's connection timeout.
=item reconnect_interval => $reconnect_interval
If the connection to the node was lost, the client will try to restore the
connection when you execute next command. By default reconnection is performed
immediately, on next command execution. If the C<reconnect_interval> parameter
is specified, the client will try to reconnect only after this interval and
commands executed between reconnections will be queued. The client will try to
reconnect to every available node before raise the error.
reconnect_interval => 5,
Not set by default.
=item handle_params => \%params
Specifies L<AnyEvent::Handle> parameters.
handle_params => {
autocork => 1,
linger => 60,
}
Enabling of the C<autocork> parameter can improve performance. See
documentation on L<AnyEvent::Handle> for more information.
=item default_headers => \%headers
Specifies default headers for all outgoing frames.
( run in 0.771 second using v1.01-cache-2.11-cpan-0d23b851a93 )