package CloudStore::Gearman;
use warnings;
use strict;

use Gearman::Client;

use Data::Dump qw(dump);

sub gearman {
	my $gearman = Gearman::Client->new;
	$gearman->job_servers('127.0.0.1:4730');
	return $gearman;
}

sub gearman_do {
	my $self = shift @_;
	my $func = shift @_;
	my $body = join(' ', @_) . "\n";
	warn "## gearman_do $func [$body]\n";

	my $result = $self->gearman->do_task( $func => $body );
	warn "##>> ",dump($result),$/ if $ENV{DEBUG};
	return $$result;
}

1;
