X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote%2FRole%2FConnector.pm;h=8ad06c239da6e95cea54f0b6cae75e16c1651c30;hp=4f008d731f89bec0af75fe00f72ae1e02e56a955;hb=55c0d0209fa9d9265ff178f54ae9fe5fdddef3c1;hpb=f8080c1c188fa6c4589ffcad8793e0cf7a8d4bdb diff --git a/lib/Object/Remote/Role/Connector.pm b/lib/Object/Remote/Role/Connector.pm index 4f008d7..8ad06c2 100644 --- a/lib/Object/Remote/Role/Connector.pm +++ b/lib/Object/Remote/Role/Connector.pm @@ -2,18 +2,18 @@ package Object::Remote::Role::Connector; use Module::Runtime qw(use_module); use Object::Remote::Future; -use Object::Remote::Logging qw(:log :dlog ); +use Object::Remote::Logging qw(:log :dlog router); use Moo::Role; requires '_open2_for'; -#TODO return to 10 seconds after debugging -#has timeout => (is => 'ro', default => sub { { after => 10 } }); -has timeout => (is => 'ro', default => sub { { after => 10 } }); +has timeout => (is => 'ro', default => sub { 10 }); + +BEGIN { router()->exclude_forwarding; } sub connect { my $self = shift; - Dlog_debug { "Perparing to create connection with args of: $_" } @_; + Dlog_debug { "Preparing to create connection with args of: $_" } @_; my ($send_to_fh, $receive_from_fh, $child_pid) = $self->_open2_for(@_); my $channel = use_module('Object::Remote::ReadChannel')->new( fh => $receive_from_fh @@ -45,21 +45,18 @@ sub connect { log_trace { "initialized events on channel for child pid '$child_pid'; creating timeout" }; Object::Remote->current_loop ->watch_time( - %{$self->timeout}, + after => $self->timeout, code => sub { -# log_warn { "Connection timed out for child pid '$child_pid'" }; -# $f->fail("Connection timed out") unless $f->is_ready; -# undef($channel); - Dlog_trace { "Connection timeout timer has fired for child pid '$child_pid'; is_ready: $_" } $f->is_ready; + Dlog_trace {"Connection timeout timer has fired for child pid '$child_pid'; is_ready: $_" } $f->is_ready; unless($f->is_ready) { log_warn { "Connection with child pid '$child_pid' has timed out" }; - $f->fail("Connection timed out") unless $f->is_ready; + $f->fail("Connection timed out") unless $f->is_ready; } undef($channel); - + } ); - log_trace { "connection for child pid '$child_pid' has been initialized" }; + log_trace { "connection for child pid '$child_pid' has been initialized" }; $f; } }