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 {
use overload ();
use Moo;
+with 'Tak::Role::Service';
with 'Tak::Role::ObjectMangling';
has proxied => (is => 'ro', init_arg => undef, default => sub { {} });
$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;