Package: lotrpc
lotrpc: RPC abstraction layerlotrpc unifies a lot of RPC protocols.protocols:XML-RPChttp://xmlrpc.scripting.com/JSON RPChttps://www.jsonrpc.org/specificationMessagePack RPChttps://msgpack.org/gRPChttps://grpc.io/ZeroRPChttps://www.zerorpc.io/One RPC to rule them all, One RPC to find them, One RPC to bring them all, and in the darkness bind them.installpython -m venv your-dircd your-dir./bin/pip install lotrpcinstall headpython -m venv your-dircd your-dir./bin/pip install -rhttps://github.com/wtnb75/lotrpc/raw/master/requirements.txt./bin/pip install -e "git+https://github.com/wtnb75/lotrpc.git#egg=lotrpc"Usageclient-server examplexmlrpc./bin/python -m lotrpc.clsrv server xml./bin/python -m lotrpc.clsrv client xml./bin/python -m lotrpc.clsrv benchmark xml --filter 'name!~process'json-rpc./bin/python -m lotrpc.clsrv server json./bin/python -m lotrpc.clsrv client jsoncurl -X POST -d '{"method":"hello", "jsonrpc":"2.0", "params":["a","b","c"]}'http://localhost:9999/./bin/python -m lotrpc.clsrv benchmark jsonmsgpack-rpc./bin/python -m lotrpc.clsrv server msgpack./bin/python -m lotrpc.clsrv client msgpack./bin/python -m lotrpc.clsrv benchmark mp --filter 'name!~process'./bin/python -m lotrpc.clsrv benchmark msgpack --filter 'name=sync'msgpack-rpc with mprpc./bin/python -m lotrpc.clsrv server mp./bin/python -m lotrpc.clsrv client mp./bin/python -m lotrpc.clsrv benchmark mp --filter 'name!~process'./bin/python -m lotrpc.clsrv benchmark msgpack --filter 'name=sync'grpc./bin/python -m lotrpc.clsrv server grpc --options '{"source":"examples/grpc/hello.proto"}'./bin/python -m lotrpc.clsrv client grpc --options '{"source":"examples/grpc/hello.proto"}' --method Greeter.SayHello --params '{"name":"xyzxyz"}'./bin/python -m lotrpc.clsrv benchmark grpc --options '{"source":"examples/grpc/hello.proto"}' --method Greeter.SayHello --params '{"name":"xyzxyz"}' --filter 'name!~process'zerorpc./bin/python -m lotrpc.clsrv server zero./bin/python -m lotrpc.clsrv client zero./bin/zerorpc --json tcp://localhost:9999 hello '{"hello":"world"}'./bin/python -m lotrpc.clsrv benchmark zero --filter 'name!~process'client usage (CLI)# ./bin/python -m lotrpc.clsrv
Usage: clsrv.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  benchmark     start benchmark client
  client        serialized client
  client-async  client with asyncio
  client-pool   client with thread pool
  client-ppool  client with process pool
  listmode      list rpc mode
  proxy         start proxy server
  proxy-auth    start proxy with authentication example
  server        start server

# ./bin/python -m lotrpc.clsrv client --help
Usage: clsrv.py client [OPTIONS] [MODE] [ADDR]

  serialized client

Options:
  --options TEXT
  --num INTEGER
  --method TEXT
  --params TEXT
  --verbose / --no-verbose
  --help                    Show this message and exit.

# ./bin/python -m lotrpc.clsrv client json http://localhost:9999/endpoint --method hello --params '{"hello":"world"}'

# nc -l 9999
POST /endpoint HTTP/1.1
Host: localhost:9999
User-Agent: python-requests/2.21.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
content-type: application/json
Content-Length: 76

{"method": "hello", "params": {"hello": "world"}, "jsonrpc": "2.0", "id": 0}client usage (Python)importlotrpc# JSON RPCcl=lotrpc.json.Client("http://localhost:9999/endpoint")# XML-RPCcl=lotrpc.xml.Client("http://localhost:9999/endpoint")# MessagePack-RPCcl=lotrpc.msgpack.Client("http://localhost:9999/endpoint")# ZeroRPCcl=lotrpc.zero.Client("http://localhost:9999/endpoint")## call itres=cl.call("hello",{"hello":"world"})print(res)server(dispatcher) usage (Python)importlotrpcclassHelloDispatcher(lotrpc.SimpleDispatcher):defdo_hello(self,params):return{"result":"OK1"}defdo_goodbye(self,params):return{"result":"OK2"}# JSON RPCsrv=lotrpc.json.Server("http://localhost:9999/endpoint")# XML-RPCsrv=lotrpc.xml.Server("http://localhost:9999/endpoint")# MessagePack-RPCsrv=lotrpc.msgpack.Server("http://localhost:9999/endpoint")# ZeroRPCsrv=lotrpc.zero.Server("http://localhost:9999/endpoint")## serve itsrv.serve(HelloDispatcher())proxy(client) -> xmlrpc -(proxy)-> jsonrpc (server)./bin/python -m lotrpc.clsrv proxy xmlhttp://localhost:9999/jsonhttp://localhost:9998/./bin/python -m lotrpc.clsrv server jsonhttp://localhost:9998/./bin/python -m lotrpc.clsrv client xmlhttp://localhost:9999/does not work...clientgrpc + process poolmsgpack + process poolxml + process poolzero + process poolaioxml + thread pool, process pool, asyncioaiojson + thread pool, process pool, asyncioclient-serverserver=mp, client=msgpackserver cannot work asyncaioxmlaiojsonzeroxmlmpTODOWork in ProgressSun RPC(for test) ./bin/python -m lotrpc.rpcgenGolang net/rpcBSON RPCthriftJava RMILinkspypicoveragelocal pypi repo