- class toto.worker.TotoWorkerService(conf_file=None, **kwargs)¶
Instances can be configured in three ways:
- (Most common) Pass the path to a config file as the first parameter to the constructor.
- Pass config parameters as command line arguments to the initialization script.
- Pass keyword arguments to the constructor.
Precidence is as follows:
Keyword args, config file, command line
The following method will normally be your only interaction with an instance of TotoWorkerService
- class toto.worker.TotoWorker(method_module, socket_address, db_connection, compression=None, serialization=None)¶
The worker is responsible for processing all RPC calls. An instance will be initialized for each incoming request.
You can set the module to use for method delegation via the method_module parameter. Methods are modules that contain an invoke function:
def invoke(handler, parameters)
The request worker instance will be passed as the first parameter to the invoke function and provides access to the server’s database connection. Request parameters will be passed as the second argument to the invoke function.
Any value returned from a method invocation will be sent to the caller, closing the message->response cycle. If you only need to let the caller know that the task has begun, you should decorate your invoke function with @toto.invocation.asynchronous to send a response before processing begins.