el free to setup your C<$driver>
this way:
package My::Workers::One;
use Moose;
use JSON::XS;
extends 'Gearman::Driver::Worker::Base';
# this method will be registered with gear
ode_json {
my ( $self, $result ) = @_;
return JSON::XS::encode_json($result);
}
sub decode_json {
my ( $self, $workload ) = @_;
return JSON::XS::decode_json($w
_method_by_name($method)->body,
decode => 'decode_json',
encode => 'encode_json',
name => $method,
},
method will be returned to the Gearman
client. This is useful to serialize Perl datastructures to JSON
before sending them back to the client.
sub do_some_job : Job : Encode : Decode {
my
ad ) = @_;
return { message => 'OK', status => 1 };
# calls 'encode' and returns JSON string: {"status":1,"message":"OK"}
}
sub custom_encoder : Job : Encode(enc_yaml) : Deco
lf, $result ) = @_;
return JSON::XS::encode_json($result);
}
sub decode {
my ( $self, $workload ) = @_;
return JSON::XS::decode_json($workload);
}
sub enc_yam