fugue.rpc
fugue.rpc.base
- class fugue.rpc.base.EmptyRPCHandler[source]
Bases:
RPCHandlerThe class representing empty
RPCHandler
- class fugue.rpc.base.NativeRPCClient(server, key)[source]
Bases:
RPCClientNative RPC Client that can only be used locally. Use
make_client()to create this instance.- Parameters:
server (NativeRPCServer) – the parent
NativeRPCServerkey (str) – the unique key for the handler and this client
- class fugue.rpc.base.NativeRPCServer(conf)[source]
Bases:
RPCServerNative RPC Server that can only be used locally.
- Parameters:
conf (Any) – the Fugue Configuration Tutorial
- make_client(handler)[source]
Add
handlerand correspondentNativeRPCClient- Parameters:
handler (Any) – RPChandler like object
- Returns:
the native RPC client
- Return type:
- class fugue.rpc.base.RPCFunc(func)[source]
Bases:
RPCHandlerRPCHandler wrapping a python function.
- Parameters:
func (Callable) – a python function
- class fugue.rpc.base.RPCHandler[source]
Bases:
RPCClientRPC handler hosting the real logic on driver side
- property running: bool
Whether the handler is in running state
- start()[source]
Start the handler, wrapping
start_handler()- Returns:
the instance itself
- Return type:
- stop()[source]
Stop the handler, wrapping
stop_handler()- Return type:
None
- class fugue.rpc.base.RPCServer(conf)[source]
Bases:
RPCHandler,ABCServer abstract class hosting multiple
RPCHandler.- Parameters:
conf (Any) – the Fugue Configuration Tutorial
- invoke(key, *args, **kwargs)[source]
Invoke the correspondent handler
- Parameters:
key (str) – key of the handler
args (Any)
kwargs (Any)
- Returns:
the return value of the handler
- Return type:
Any
- abstract make_client(handler)[source]
Make a
RPCHandlerand return the correspondentRPCClient- Parameters:
handler (Any) – RPChandler like object
- Returns:
the client connecting to the handler
- Return type:
- register(handler)[source]
Register the hander into the server
- Parameters:
handler (Any) – RPChandler like object
- Returns:
the unique key of the handler
- Return type:
str
- start_handler()[source]
Wrapper to start the server, do not override or call directly
- Return type:
None
- fugue.rpc.base.make_rpc_server(conf)[source]
Make
RPCServerbased on configuration. If ‘fugue.rpc.server` is set, then the value will be used as the server type for the initialization. Otherwise, aNativeRPCServerinstance will be returned- Parameters:
conf (Any) – the Fugue Configuration Tutorial
- Returns:
the RPC server
- Return type:
- fugue.rpc.base.to_rpc_handler(obj)[source]
Convert object to
RPCHandler. If the object is alreadyRPCHandler, then the original instance will be returned. If the object isNonethenEmptyRPCHandlerwill be returned. If the object is a python function thenRPCFuncwill be returned.- Parameters:
obj (Any) – RPChandler like object
- Returns:
the RPC handler
- Return type:
fugue.rpc.flask
- class fugue.rpc.flask.FlaskRPCClient(key, host, port, timeout_sec)[source]
Bases:
RPCClientFlask RPC Client that can be used distributedly. Use
make_client()to create this instance.- Parameters:
key (str) – the unique key for the handler and this client
host (str) – the host address of the flask server
port (int) – the port of the flask server
timeout_sec (float) – timeout seconds for flask clients
- class fugue.rpc.flask.FlaskRPCServer(conf)[source]
Bases:
RPCServerFlask RPC server that can be used in a distributed environment. It’s required to set
fugue.rpc.flask_server.hostandfugue.rpc.flask_server.port. Iffugue.rpc.flask_server.timeoutis not set, then the client could hang until the connection is closed.- Parameters:
conf (Any) – the Fugue Configuration Tutorial
Examples
conf = { "fugue.rpc.server": "fugue.rpc.flask.FlaskRPCServer", "fugue.rpc.flask_server.host": "127.0.0.1", "fugue.rpc.flask_server.port": "1234", "fugue.rpc.flask_server.timeout": "2 sec", } with make_rpc_server(conf).start() as server: server...
- make_client(handler)[source]
Add
handlerand correspondentFlaskRPCClient- Parameters:
handler (Any) – RPChandler like object
- Returns:
the flask RPC client that can be distributed
- Return type: