| RPC-Object documentation | view source | Contained in the RPC-Object distribution. |
RPC::Object - A lightweight implementation for remote procedure calls
On server
use RPC::Object::Broker; $b = $RPC::Object::Broker->new(preload => \@preload_modules); $b->start();
On client
use RPC::Object;
$o = RPC::Object->new("$host:$port", 'method_a', 'TestModule');
my $ans1 = $o->method_b($arg1, $arg2);
my @ans2 = $o->method_c($arg3, $arg4);
# To access the global instance
# allocate and initialize first,
RPC::Object->new("$host:$port", 'method_a', 'TestModule');
...
$global = RPC::Object->get_instance("$host:$port", 'TestModule');
TestModule
package TestModule;
use threads;
...
sub method_a {
my $class = shift;
my $self : shared;
...
return bless $self, $class;
} }
Please see more examples in the test scripts.
RPC::Object is designed to be very simple and only works between
Perl codes, This makes its implementation only need some core Perl
modules, e.g. Socket and Storable.
Other approaches like SOAP or XML-RPC are too heavy for simple tasks.
Thread awareness
All modules and objects invoked by RPC::Object should aware the
multi-threaded envrionment.
Constructor and Destructor
The Module could name its constructor any meaningful name. it do not
have to be new, or create, etc...
There is no guarantee that the destructor will be called as expected.
Global instance
To allocate global instances, use the RPC::Object::new()
method. Then use the RPC::Object::get_instance() method to access
them.
Scalars leaked warning
This is expected for now. The walkaround is to close STDERR.
Need re-bless RPC::Object
threads::shared prior to 0.95 does not support bless on shared
refs, if an <RPC::Object> is passed across threads, it may need
re-bless to RPC::Object.
Jianyuan Wu <jwu@cpan.org>
Copyright 2006 -2007 by Jianyuan Wu <jwu@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| RPC-Object documentation | view source | Contained in the RPC-Object distribution. |