| Gearman-Driver documentation | Contained in the Gearman-Driver distribution. |
Gearman::Driver::Adaptor - Adaptor to gearman libraries
Gearman::Driver works with Gearman::XS as well as with the pure
Perl modules Gearman and Gearman::Server. By default it tries
to use Gearman::XS. If that fails Gearman is used. You can
also export an environment variable GEARMAN_DRIVER_ADAPTOR to
force usage of Gearman even if you have Gearman::XS.
Example:
export GEARMAN_DRIVER_ADAPTOR="Gearman::Driver::Adaptor::XS"export GEARMAN_DRIVER_ADAPTOR="Gearman::Driver::Adaptor::PP"See Gearman::Driver.
See Gearman::Driver.
| Gearman-Driver documentation | Contained in the Gearman-Driver distribution. |
package Gearman::Driver::Adaptor; use Moose; use Class::MOP;
has 'backend' => ( builder => '_build_backend', handles => [ qw( add_servers add_function error work ) ], is => 'ro', ); has 'server' => ( is => 'rw', isa => 'Str', required => 1, ); sub _build_backend { my ($self) = @_; my @classes = qw(Gearman::Driver::Adaptor::XS Gearman::Driver::Adaptor::PP); unshift @classes, $ENV{GEARMAN_DRIVER_ADAPTOR} if defined $ENV{GEARMAN_DRIVER_ADAPTOR}; foreach my $class (@classes) { eval "require $class"; unless ($@) { return $class->new( server => $self->server ); } } die "None of the supported adaptors could be loaded: %s\n", join ', ', @classes; } sub BUILD { my ($self) = @_; $self->add_servers( $self->server ); }
1;