
Acme::RPC - Easy remote function and method call and more

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().

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.
/(No parameter.)
action=dumpGives an index of packages, subroutines, variables in those subroutines, closures in those variables, and so on.
output=jsonOutput 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/somethingThere 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 to dump.
action=callInvokes a method or code ref. It does not invoke object references. Requires either oid or path be specified. You may also set arg0, 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=methodUsed with method=[method name] and either an oid=[oid] or path=[path] to an object reference, it calls that method on that object. As above, takes argument data from arg0, arg1, arg2, etc.
lazy=1Avoid rebuilding the entire object graph to speed things up a bit.
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.
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.

Original version; created by h2xs 1.23 with options:
-A -C -X -b 5.8.0 -c -n Acme::RPC


Scott Walters, <scott@slowass.net>

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.