Net::IMP::Remote - connect to IMP plugins outside the process
perl imp-relay.pl ... -M Net::IMP::Remote=addr=imp-host:2000 ...
Net::IMP::Remote redirects the interaction with the IMP API to a server process, which might be on the local or on a different machine. Current implementation feature connection using UNIX domain sockets or TCP sockets.
The RPC functionality is described in Net::IMP::Remote::Protocol. Net::IMP::Remote::Connection implements interactions using the defined RPCs over a flexible wire protocol. The default wire implementation using the Storable library is done in Net::IMP::Remote::Storable. There is an alternative implementation with the Sereal library in Net::IMP::Remote::Sereal. Net::IMP::Remote::Client and Net::IMP::Remote::Server implement the client and server side of the connection, while Net::IMP::Remote finally implements the usual IMP interface, so that this plugin can be used whereever other IMP plugins can be used, although it's used best in data providers offering an integration into their event loop.
Unlike other solutions like ICAP IMP tries to keep the overhead small. A new connection to the IMP RPC server is done once, when the factory object is created. Traffic for all analyzers created from the factory will be multiplexed over the same connection, thus eliminating costly connection setup. All RPC calls, except the initial get_interface after creating the factory object, are asynchronous, because they don't need an immediate reply to continue operation.
While it is possible to use Net::IMP::Remote without an event loop it is slower, because all read and write operation will block until they are done. But the data provider might provide a simple event loop object within the new_factory call:
new_factory
my $factory = Net::IMP::Remote->new_factory( addr => 'host:port', eventlib => myEventLib->new );
The event lib object should implement the following simple interface
If callback is given it will set it up as a read handler, e.g. whenever the file handle gets readable the callback will be called without arguments. If callback is not given it will remove any existing callback, thus ignoring if the file handle gets readable.
Similar to onread, but for write events
onread
This will setup a timer, which will be called after after seconds and call callback. If interval is set it will reschedule the timer again and again to be called every interval seconds. Ths method returns an object timer_obj. If this object gets destroyed the timer will be canceled.
after
callback
interval
timer_obj
See TODO file in distribution
Storable Sereal::Encoder Sereal::Decoder
Steffen Ullrich
To install Net::IMP::Remote, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::IMP::Remote
CPAN shell
perl -MCPAN -e shell install Net::IMP::Remote
For more information on module installation, please visit the detailed CPAN module installation guide.