From: Tyler Riddle Date: Mon, 8 Oct 2012 19:13:02 +0000 (-0700) Subject: fix indentation levels; remove dead comments and code X-Git-Tag: v0.003001_01~103 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=37efeb68748dd589455d8ae58d39e74700abdd67;p=scpubgit%2FObject-Remote.git fix indentation levels; remove dead comments and code --- diff --git a/lib/Object/Remote.pm b/lib/Object/Remote.pm index 9dbb70e..feee52a 100644 --- a/lib/Object/Remote.pm +++ b/lib/Object/Remote.pm @@ -8,7 +8,7 @@ use Module::Runtime qw(use_module); our $VERSION = '0.002003'; # 0.2.3 BEGIN { - Object::Remote::Logging->init_logging; + Object::Remote::Logging->init_logging; } sub new::on { diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index 8e132a6..80ac4c1 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -77,8 +77,8 @@ has read_channel => ( 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(@_); }); }, ); @@ -181,15 +181,15 @@ sub _build__json { } )->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; } ); } diff --git a/lib/Object/Remote/FatNode.pm b/lib/Object/Remote/FatNode.pm index d963ea6..6b65a25 100644 --- a/lib/Object/Remote/FatNode.pm +++ b/lib/Object/Remote/FatNode.pm @@ -61,9 +61,9 @@ my @after_inc; 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'; diff --git a/lib/Object/Remote/LogRouter.pm b/lib/Object/Remote/LogRouter.pm index 12ce1a9..671856a 100644 --- a/lib/Object/Remote/LogRouter.pm +++ b/lib/Object/Remote/LogRouter.pm @@ -9,32 +9,7 @@ has subscriptions => ( is => 'ro', required => 1, default => sub { [] } ); 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) = @_; @@ -71,17 +46,8 @@ sub handle_log_message { #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 diff --git a/lib/Object/Remote/MiniLoop.pm b/lib/Object/Remote/MiniLoop.pm index 5be3100..463ca79 100644 --- a/lib/Object/Remote/MiniLoop.pm +++ b/lib/Object/Remote/MiniLoop.pm @@ -6,7 +6,6 @@ use Object::Remote::Logging qw( :log :dlog ); 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 @@ -93,9 +92,9 @@ sub watch_time { } 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}; diff --git a/lib/Object/Remote/ModuleLoader.pm b/lib/Object/Remote/ModuleLoader.pm index 0e59604..8b2e6c2 100644 --- a/lib/Object/Remote/ModuleLoader.pm +++ b/lib/Object/Remote/ModuleLoader.pm @@ -29,9 +29,9 @@ has inc_hook => (is => 'lazy'); 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 } diff --git a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm index 4f74078..58eb93d 100644 --- a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm +++ b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm @@ -14,6 +14,8 @@ use Moo::Role; 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 @@ -29,8 +31,28 @@ sub _build_module_sender { 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); diff --git a/lib/Object/Remote/Role/LogForwarder.pm b/lib/Object/Remote/Role/LogForwarder.pm index 4a4f4af..d65ed17 100644 --- a/lib/Object/Remote/Role/LogForwarder.pm +++ b/lib/Object/Remote/Role/LogForwarder.pm @@ -1,3 +1,7 @@ +#This is an experimental method for working with +#Log::Contextual crossing Object::Remote connections +#transparently + package Object::Remote::Role::LogForwarder; use Moo::Role; @@ -38,6 +42,8 @@ sub describe { 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; } diff --git a/lib/Object/Remote/Tied.pm b/lib/Object/Remote/Tied.pm index af6f7fd..0d94fd4 100644 --- a/lib/Object/Remote/Tied.pm +++ b/lib/Object/Remote/Tied.pm @@ -9,11 +9,11 @@ use strictures 1; #is passed to the constructor sub TIEHASH { - return $_[1]; + return $_[1]; } sub TIEARRAY { - return $_[1]; + return $_[1]; }