our $VERSION = '0.002003'; # 0.2.3
BEGIN {
- Object::Remote::Logging->init_logging;
+ Object::Remote::Logging->init_logging;
}
sub new::on {
weaken($self);
$ch->on_line_call(sub { $self->_receive(@_) });
$ch->on_close_call(sub {
- log_trace { "invoking 'done' on on_close handler for connection id '$id'" };
- $self->on_close->done(@_);
+ log_trace { "invoking 'done' on on_close handler for connection id '$id'" };
+ $self->on_close->done(@_);
});
},
);
}
)->filter_json_single_key_object(
__remote_tied_hash__ => sub {
- my %tied_hash;
- tie %tied_hash, 'Object::Remote::Tied', $self->_id_to_remote_object(@_);
- return \%tied_hash;
+ my %tied_hash;
+ tie %tied_hash, 'Object::Remote::Tied', $self->_id_to_remote_object(@_);
+ return \%tied_hash;
}
)->filter_json_single_key_object(
__remote_tied_array__ => sub {
- my @tied_array;
- tie @tied_array, 'Object::Remote::Tied', $self->_id_to_remote_object(@_);
- return \@tied_array;
+ my @tied_array;
+ tie @tied_array, 'Object::Remote::Tied', $self->_id_to_remote_object(@_);
+ return \@tied_array;
}
);
}
my $env_pass = '';
if (defined($ENV{OBJECT_REMOTE_LOG_LEVEL})) {
- my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
- return unless $level =~ /^\w+$/;
- $env_pass = '$ENV{OBJECT_REMOTE_LOG_LEVEL} = "' . $level . "\";\n";
+ my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
+ return unless $level =~ /^\w+$/;
+ $env_pass = '$ENV{OBJECT_REMOTE_LOG_LEVEL} = "' . $level . "\";\n";
}
my $start = stripspace <<'END_START';
has description => ( is => 'rw', required => 1 );
sub before_import { }
-sub after_import {
- my ($self, $controller, $importer, $config) = @_;
- my $logger = $controller->arg_logger($config->{logger});
-
-# TODO need to review this concept, ignore these configuration values for now
-# my $package_logger = $controller->arg_package_logger($config->{package_logger});
-# my $default_logger = $config->{default_logger};
-#
-# #when installing a new selector this will be the default
-# #logger invoked unless otherwise specified
-# $self->{default_logger} = $default_logger;
-#
-# #if the logger configuration value is specified
-# #then all logs given to the router will also be
-# #delivered to that logger
-# if (defined($logger)) {
-# $self->add_selector(sub { 1 }, $logger);
-# }
-#
-# #if the configuration specifies a package logger
-# #build a selector that matches the package and
-# #install it
-# if (defined($package_logger)) {
-# $self->add_selector( sub { $_->{package} eq $importer }, $package_logger );
-# }
-}
+sub after_import { }
sub subscribe {
my ($self, $logger, $selector, $is_temp) = @_;
#this info to the selector is a good feature
local($_) = { level => $level, package => $caller };
if ($selector->(@values)) {
- #SOLVED resolve caller_level issues with routing
- #idea: the caller level will differ in distance from the
- #start of the call stack but it's a constant distance from
- #the end of the call stack - can that be exploited to calculate
- #the distance from the start right before it's used?
- #
- #newer idea: in order for log4perl to work right the logger
- #must be invoked in the exported log_* method directly
- #so by passing the logger down the chain of routers
- #it can be invoked in that location and the caller level
- #problem doesn't exist anymore
+ #TODO issues with caller_level have not been resolved yet
+ #when a logger crosses an object::remote::connection so
$logger = $logger->($caller, { caller_level => -1 });
#TODO there is a known issue with the interaction of this
use Moo;
# this is ro because we only actually set it using local in sub run
-
has is_running => (is => 'ro', clearer => 'stop');
#maximum duration that select() will block - undef means indefinite,
#0 means no blocking, otherwise maximum time in seconds
} elsif (exists($watch{after})) {
$at = time() + $watch{after};
} elsif (exists($watch{at})) {
- $at = $watch{at};
+ $at = $watch{at};
} else {
- die "watch_time requires every, after or at";
+ die "watch_time requires every, after or at";
}
die "watch_time requires code" unless my $code = $watch{code};
sub _build_inc_hook {
my ($self) = @_;
log_debug { "Constructing module builder hook" };
- #TODO why didn't log_trace return the argument?
- logS_trace { "Done constructing module builder hook" }
- Object::Remote::ModuleLoader::Hook->new(sender => $self->module_sender);
+ my $hook = Object::Remote::ModuleLoader::Hook->new(sender => $self->module_sender);
+ log_trace { "Done constructing module builder hook" };
+ return $hook;
}
sub BUILD { shift->enable }
with 'Object::Remote::Role::Connector';
has module_sender => (is => 'lazy');
+has ulimit => ( is => 'ro' );
+has nice => ( is => 'ro' );
#if no child_stderr file handle is specified then stderr
#of the child will be connected to stderr of the parent
has perl_command => (is => 'lazy');
has watchdog_timeout => ( is => 'ro', required => 1, default => sub { 0 } );
-#TODO convert the ulimit and nice values into configurable attributes
-sub _build_perl_command {[ 'sh -c "ulimit -v 200000; nice -n 15 perl -"' ] }
+#SSH requires the entire remote command to be
+#given as one single argument to the ssh
+#command line program so this jumps through
+#some hoops
+sub _build_perl_command {
+ my ($self) = @_;
+ my $nice = $self->nice;
+ my $ulimit = $self->ulimit;
+ my $shell_code = 'sh -c "';
+
+ if (defined($ulimit)) {
+ $shell_code .= "ulimit -v $ulimit; ";
+ }
+
+ if (defined($nice)) {
+ $shell_code .= "nice -n $nice ";
+ }
+
+ $shell_code .= 'perl -"';
+
+ return [ $shell_code ];
+}
around connect => sub {
my ($orig, $self) = (shift, shift);
+#This is an experimental method for working with
+#Log::Contextual crossing Object::Remote connections
+#transparently
+
package Object::Remote::Role::LogForwarder;
use Moo::Role;
sub add_child_router {
my ($self, $router) = @_;
push(@{ $self->child_routers }, $router);
+ #TODO re-weaken when object::remote proxied
+ #weak references is figured out
# weaken(${ $self->child_routers }[-1]);
return;
}
#is passed to the constructor
sub TIEHASH {
- return $_[1];
+ return $_[1];
}
sub TIEARRAY {
- return $_[1];
+ return $_[1];
}