From: Matt S Trout Date: Sun, 6 Nov 2011 12:41:16 +0000 (+0000) Subject: switch object client to new code X-Git-Tag: v0.001001~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=13ca23bc5596a4e619cdb801e8444af30ca0631f;p=scpubgit%2FTak.git switch object client to new code --- diff --git a/lib/Tak/ObjectClient.pm b/lib/Tak/ObjectClient.pm index 2761cc6..bf3e5e3 100644 --- a/lib/Tak/ObjectClient.pm +++ b/lib/Tak/ObjectClient.pm @@ -5,41 +5,36 @@ use Moo; with 'Tak::Role::ObjectMangling'; -has world => (is => 'ro', required => 1); +has remote => (is => 'ro', required => 1); -has remote => (is => 'lazy'); +has object_service => (is => 'lazy'); -sub _build_remote { +sub _build_object_service { my ($self) = @_; - my $world = $self->world; - $world->remote_for('meta')->blocking_request( - register => object_service => 'Tak::ObjectService' - ); - $world->remote_for('object_service') + my $remote = $self->remote; + $remote->do(meta => register => object_service => 'Tak::ObjectService'); + $remote->curry('object_service'); } sub proxy_method_call { my ($self, @call) = @_; + my $client = $self->object_service; my $ready = $self->encode_objects(\@call); my $context = wantarray; - my @res = $self->remote->blocking_request(call_method => $context => $ready); - if ($res[0] eq 'RESULT') { - my $unpacked = $self->decode_objects($res[1]); - if ($context) { - return @$unpacked; - } elsif (defined $context) { - return $unpacked->[0]; - } else { - return; - } + my $res = $client->do(call_method => $context => $ready); + my $unpacked = $self->decode_objects($res); + if ($context) { + return @$unpacked; + } elsif (defined $context) { + return $unpacked->[0]; } else { - die $res[1]; + return; } } sub proxy_death { my ($self, $proxy) = @_; - $self->remote->blocking_request(remove_object => $proxy->{tag}); + $self->client->do(remove_object => $proxy->{tag}); } sub inflate { diff --git a/lib/Tak/ObjectService.pm b/lib/Tak/ObjectService.pm index 94f1248..f859bcc 100644 --- a/lib/Tak/ObjectService.pm +++ b/lib/Tak/ObjectService.pm @@ -3,6 +3,7 @@ package Tak::ObjectService; use overload (); use Moo; +with 'Tak::Role::Service'; with 'Tak::Role::ObjectMangling'; has proxied => (is => 'ro', init_arg => undef, default => sub { {} }); @@ -36,14 +37,14 @@ sub handle_call_method { $invocant->$method(@args); } 1; - } or return FAILURE => "$@"; - return RESULT => $self->encode_objects(\@res); + } or die [ failure => "$@" ]; + return $self->encode_objects(\@res); } sub handle_remove_object { my ($self, $tag) = @_; my $had = !!delete $self->proxied->{$tag}; - return RESULT => $had; + return $had; } 1;