cleanup trailing whitespace ugliness
[scpubgit/Object-Remote.git] / lib / Object / Remote / Node.pm
CommitLineData
eee9a548 1package Object::Remote::Node;
2
3use strictures 1;
4use Object::Remote::Connector::STDIO;
9031635d 5use Object::Remote::Logging qw(:log :dlog);
c824fdf3 6use Object::Remote::WatchDog;
eee9a548 7use Object::Remote;
8use CPS::Future;
9
10sub run {
55c0d020 11 my ($class, %args) = @_;
9031635d 12 log_trace { "run() has been invoked on remote node" };
55c0d020 13
eee9a548 14 my $c = Object::Remote::Connector::STDIO->new->connect;
55c0d020 15
eee9a548 16 $c->register_class_call_handler;
17
eee9a548 18 my $loop = Object::Remote->current_loop;
55c0d020 19
20 $c->on_close->on_ready(sub {
cd295a40 21 log_debug { "Node connection with call handler has closed" };
55c0d020 22 $loop->want_stop
9d64d2d9 23 });
eee9a548 24
9031635d 25 Dlog_trace { "Node is sending 'Shere' to $_" } $c->send_to_fh;
eee9a548 26 print { $c->send_to_fh } "Shere\n";
27
9d64d2d9 28 log_debug { "Node is going to start the run loop" };
cd295a40 29 #TODO the alarm should be reset after the run loop starts
30 #at a minimum - the remote side node should probably send
55c0d020 31 #a command that clears the alarm in all instances - even
32 #if the Object::Remote::Watchdog is not being used
8faf2a28 33 if ($args{watchdog_timeout}) {
34 Object::Remote::WatchDog->new(timeout => $args{watchdog_timeout});
35 } else {
36 #reset connection watchdog from the fatnode
37 alarm(0);
38 }
eee9a548 39 $loop->want_run;
40 $loop->run_while_wanted;
9d64d2d9 41 log_debug { "Run loop invocation in node has completed" };
eee9a548 42}
43
441;