Skip to content

Instantly share code, notes, and snippets.

@akahan
Created December 9, 2015 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akahan/6074293ac532f1cc6b80 to your computer and use it in GitHub Desktop.
Save akahan/6074293ac532f1cc6b80 to your computer and use it in GitHub Desktop.
# Master
my $slave_handle;
$slave_handle = AnyEvent::Handle->new(
fh => $slave->{_socket},
on_read => sub {
shift->push_read( json => sub {
my ( $h, $job_result ) = @_;
$jc->job_done( $job_id, $job_result );
});
}
);
# Поставим задачу
$slave_handle->push_write($job_mod."\n");
# Slave
$self->{_cv} = AnyEvent->condvar;
my $master_handle;
$master_handle = AnyEvent::Handle->new(
fh => $self->{_socket},
on_read => sub {
shift->push_read( line => sub {
my ( $h, $job_mod ) = @_;
debug "Slave $self->{_id} got $job_mod";
load_class($job_mod);
my $result = $job_mod->execute();
$h->push_write( json => $result );
});
}
);
$self->cv->recv;
@akahan
Copy link
Author

akahan commented Dec 9, 2015

[debug] [09.12.2015 16:55:19] [13609] Slave choosed: 1
[debug] [09.12.2015 16:55:19] [13610] Slave 1 got AsyncJobsServer::Job::MemInfo
[debug] [09.12.2015 16:55:20] [13609] Requested command: job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment