Skip to main content

RPC abstraction layer

Project description

lotrpc: RPC abstraction layer

lotrpc unifies a lot of RPC protocols.


One RPC to rule them all, One RPC to find them, One RPC to bring them all, and in the darkness bind them.


  • python -m venv your-dir
  • cd your-dir
  • ./bin/pip install lotrpc

install head


client-server example

  • xmlrpc
    • ./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 json
      • curl -X POST -d '{"method":"hello", "jsonrpc":"2.0", "params":["a","b","c"]}' http://localhost:9999/
        • ./bin/python -m lotrpc.clsrv benchmark json
  • msgpack-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

  --help  Show this message and exit.

  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: client [OPTIONS] [MODE] [ADDR]

  serialized client

  --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)

import lotrpc

cl = lotrpc.json.Client("http://localhost:9999/endpoint")

cl = lotrpc.xml.Client("http://localhost:9999/endpoint")

# MessagePack-RPC
cl = lotrpc.msgpack.Client("http://localhost:9999/endpoint")

# ZeroRPC
cl ="http://localhost:9999/endpoint")

## call it
res ="hello", {"hello": "world"})

server(dispatcher) usage (Python)

import lotrpc

class HelloDispatcher(lotrpc.SimpleDispatcher):
    def do_hello(self, params):
        return {"result": "OK1"}

    def do_goodbye(self, params):
        return {"result": "OK2"}

srv = lotrpc.json.Server("http://localhost:9999/endpoint")

srv = lotrpc.xml.Server("http://localhost:9999/endpoint")

# MessagePack-RPC
srv = lotrpc.msgpack.Server("http://localhost:9999/endpoint")

# ZeroRPC
srv ="http://localhost:9999/endpoint")

## serve it


does not work...

  • client
    • grpc + process pool
    • msgpack + process pool
    • xml + process pool
    • zero + process pool
    • aioxml + thread pool, process pool, asyncio
    • aiojson + thread pool, process pool, asyncio
  • client-server
    • server=mp, client=msgpack
  • server cannot work async
    • aioxml
    • aiojson
    • zero
    • xml
    • mp


  • Work in Progress
    • Sun RPC
      • (for test) ./bin/python -m lotrpc.rpcgen
  • Golang net/rpc
  • thrift
  • Java RMI


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

lotrpc-0.1.2-py3-none-any.whl (23.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page