EV-Gearman

 view release on metacpan or  search on metacpan

lib/EV/Gearman.pm  view on Meta::CPAN

=over

=item C<host =E<gt> $str>

=item C<port =E<gt> $int>

TCP host and port. Default port: C<4730>. Mutually exclusive with
C<path>.

Name resolution is currently synchronous: a non-numeric C<host> is
passed straight to C<getaddrinfo>, which can block the event loop
for the system resolver timeout. Pass an IP literal (or pre-resolve
once) to keep reconnect cycles fully non-blocking.

=item C<path =E<gt> $str>

Unix-domain socket path. Mutually exclusive with C<host>.

Note that a C<connect(2)> to a unix socket completes inline, so the
connection is fully established (and C<on_connect> has already fired)
before C<new> returns — a C<< $g->on_connect(...) >> assigned after
construction will never fire for it. Pass C<on_connect> to the
constructor instead (the same can theoretically happen for a TCP
connect that completes immediately).

=item C<loop =E<gt> $ev_loop>

EV loop to attach to. Default: C<EV::default_loop>.

=item C<priority =E<gt> $num>

EV watcher priority in C<-2 .. +2>. Higher = serviced before other
EV watchers in the same iteration. Default C<0>.

=item C<keepalive =E<gt> $seconds>

TCP keepalive idle interval. C<0> disables. Ignored on Unix sockets.

=back

=head3 Timeouts

=over

=item C<connect_timeout =E<gt> $ms>

Abort an in-progress non-blocking connect after this many ms. C<0>
= no timeout (default).

=item C<command_timeout =E<gt> $ms>

Per-request timeout. The request at the head of the pending queue is
given this many ms from the moment it is written to the socket; if it
is still unanswered when its budget expires, the connection is torn
down with C<"command timeout">. The budget is independent of
unrelated traffic: other packets arriving meanwhile neither extend
the head request's budget nor shorten it, and once the head is
answered the next request's own budget applies. A slow reply that
keeps dribbling in is therefore safe as long as the request completes
within its budget — and a genuinely stuck request dies on schedule
even on an otherwise busy connection. C<0> = no timeout (default).

=back

=head3 Reconnect

=over

=item C<reconnect =E<gt> $bool>

Enable automatic reconnect on transport errors.

=item C<reconnect_delay =E<gt> $ms>

Wait this many ms before each reconnect attempt. Default C<1000>.
The delay is always honored via a timer, so even C<0> defers
through the event loop (no synchronous retry recursion).

=item C<max_reconnect_attempts =E<gt> $num>

Give up after this many consecutive failures and emit
C<"max reconnect attempts reached">. C<0> = unlimited (default).

=back

After a reconnect, all worker C<CAN_DO>/C<CAN_DO_TIMEOUT>
registrations and the C<exceptions> option are re-sent
automatically.

=head3 Worker / option flags

=over

=item C<exceptions =E<gt> $bool>

If true, the C<exceptions> option is sent on every connect, so
foreground clients receive C<WORK_EXCEPTION> packets. For workers,
this also enables forwarding C<die> messages from sync callbacks
as exceptions instead of the C<WORK_FAIL> (C<WORK_EXCEPTION> is
terminal at the server; sending both would earn a C<JOB_NOT_FOUND>).

=item C<client_id =E<gt> $str>

Sent as C<SET_CLIENT_ID> on every connect. Visible in the admin
C<workers> output.

=item C<grab_unique =E<gt> $bool>

If true, the worker GRAB loop uses C<GRAB_JOB_UNIQ>, so the job
object exposes the unique key supplied by the submitter.

=back

=head3 Event handlers

=over

=item C<on_error =E<gt> $cb-E<gt>($errstr)>

Connection-level error callback. Default: C<warn>. User callbacks
are run under C<G_EVAL>.



( run in 1.402 second using v1.01-cache-2.11-cpan-0fb53d1c279 )