json_rpc package¶
Submodules¶
json_rpc.variants module¶
-
class
json_rpc.variants.ErrorCode[source]¶ Bases:
enum.EnumAn enum object is having error definitions which was defined by the protocol.
code message meaning -32700 Parse error Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. -32600 Invalid Request The JSON sent is not a valid Request object. -32601 Method not found The method does not exist / is not available. -32602 Invalid params Invalid method parameter(s). -32603 Internal error Internal JSON-RPC error. -32000 to -32099 Server error Reserved for implementation-defined server-errors. -
INTERNAL_ERROR= -32603¶
-
INVALID_PARAMS= -32602¶
-
INVALID_REQUEST= -32600¶
-
METHOD_NOT_FOUND= -32601¶
-
PARSE_ERROR= -32700¶
-
UNEXPECTED_ERROR= -32099¶ error for application specific error which is unexpected
-
Module contents¶
-
json_rpc.make_request(method: str, params: typing.Union[typing.List, typing.Dict[str, typing.Any]], request_id: typing.Union[str, NoneType] = None)[source]¶ Helper function to create a request follows JSON-rpc protocol.
>>> make_request('aa', {"aa": "rpc"}, '111') {"jsonrpc": "2.0", "method": "aa", "params": {"aa": "rpc"}, "id": "111"}
-
json_rpc.register(target)[source]¶ Decorator to register functions as Remote procedure.
In default, rpc method name will be the name of function. First argument would be a name of the method.
Example:
>>> @register ... def func_x(a, b, c): ... pass ...
>>> @register('named') ... def func_named(a, b, c): ... pass ...