NAME
Acme::RPC - Easy remote function and method call and more
SYNOPSIS
use Acme::RPC;
our $test2 = t2->new();
package t2;
sub new { bless { one => 1 }, $_[0] };
sub add { ($_[1] + $_[2]); }'
Then go to:
http://localhost:7777/?path=%24test2/add()&action=call&arg0=10&arg1=15
The path
part, decoded, reads $test2/add()
.
DESCRIPTION
By my estimate, there are over 10,000 RPC modules on CPAN. Each one makes RPC more difficult than the one before it. They all want you to pass tokens back and forth, register handlers for which methods may be called, create sessions, and so. With Acme::RPC, there's only one required step: GET or POST to your method. And if you don't know which methods are available, Acme::RPC will help you find them. Even if they're hidden away in objects referenced from inside of closures.
The RPC daemon starts after the program finishes, or whe it does Event::loop
.
CGI Parameters
/
-
(No parameter.)
action=dump
-
Gives an index of packages, subroutines, variables in those subroutines, closures in those variables, and so on.
output=json
-
Output a JavaScript datastructures (JSON) instead of Perl style Data::Dumper or HTML. The main index page otherwise prints out HTML (under the assumption that a human will be digging through it) and other things mostly emit Data::Dumper formatted text.
oid=(number)
path=/path/to/something
-
There are two ways to specify or reference an object: by it's
oid
or by the path to navigate to it from the main index screen. JSON and HTML output from the main index screen specifies the oids of each item and the paths can be derived from the labels in the graph. With no action specified, it defaults todump
. action=call
-
Invokes a method or code ref. It does not invoke object references. Requires either
oid
orpath
be specified. You may also setarg0
,arg1
,arg2
etc GET or POST parameters to pass data into the function. There's currently no way to pass in an arbitrary object (see TODO below). action=method
-
Used with
method=[method name]
and either anoid=[oid]
orpath=[path]
to an object reference, it calls that method on that object. As above, takes argument data fromarg0
,arg1
,arg2
, etc. lazy=1
-
Avoid rebuilding the entire object graph to speed things up a bit.
TODO
oidarg[n]
to pass in an arbitrary other object as a parameter.
JSON posted to the server to specify arguments.
JSON posted to the server to specify the entire function/method call.
BUGS
There is no security. At all.
A lot of this stuff hasn't been tested. At all.
You will leak memory like crazy.
Really, I wasted about three days on this, so I'm very much in a "it compiles, ship it!" mode. Want to see it rounded out better? Drop me some email.
HISTORY
SEE ALSO
AUTHOR
Scott Walters, <scott@slowass.net>
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Scott Walters
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.
USE AT YOUR OWN RISK.
NOT SUITABLE FOR ANY PURPOSE.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 502:
You forgot a '=back' before '=head2'