DESCRIPTION
This class is an abstract base class used to implement RPC executers. That is, modules meant to have their methods called from another process, and have the results passed back to the original caller. The communication happens over a read-write filehandle such as a socket by passing UR::Service::RPC::Message objects back and forth.Executors are subordinate to a UR::Service::RPC::Server object which handles decoding the message passed over the socket, calling the method on the correct executor in the right context, and returning the result back through the file handle.
PROPERTIES
- fh => IO::Handle
- File handle messages are received on and responses are sent to
- use_sigio => Boolean
- If true, the Server will set up a callback on the IO signal to handle execution, so the Server does not need to block in loop().
METHODS
- authenticate
-
$bool = $exec->authenticate($msg);
This is called by execute() after the message object is deserialized from the filehandle. The default implementation just returns true. Subclasses can override this to examine the UR::Service::RPC::Message object and return true or fale whether it should allow or disallow execution. If authentication fails, the Executor should modify the Message object in-place with a proper return value and exception.
- execute
-
$exec->execute();
Called when the Server detects data is available to read on its file handle. It deserializes the message and calls authenticate. If authentication fails, it immediately passes the message object back to the caller.
If authentication succeedes, it calls the appropriate method in the Executor package, and creates a new Message object with the return value to pass back to the caller.
- close_connection
-
$exec->close_connection();
Called by execute() when it detects that the file handle has closed.
Derived classes should define additional methods that then become callable by execute().