caldera

asyncio-compatible minimal RPC


Keywords
asyncio, rpc
License
Other
Install
pip install caldera

Documentation

very minimal rpc using asyncio

Build Status

documentation

basic usage

import caldera
import asyncio

rios = caldera.Server()
remote = rios.remote_method

@remote
def ultimate_question():
    return 42

@asyncio.coroutine
def client_test():

    rioc = caldera.Client()
    yield from rioc.connect(
        host="localhost",
        port=9000)

    ans = yield from rioc.ultimate_question()
    print("ultimate answer: {ans}".format(**locals()))

    rioc.close()

loop = asyncio.get_event_loop()

loop.run_until_complete(
    rios.serve(
        host="localhost",
        port=9000))

loop.run_until_complete(client_test())
loop.close()

to include caldera in your project, just download the single caldera script. i may eventually add a pypi package, but definitely not yet.

behind the scenes

during the .serve() coroutine, a collection of all remote methods is built. this collection is sent to clients upon .connect(), and the client creates each of them as a method on the Client object.

all data is transmitted as "vanilla" json, with a null byte (b"\x00") as a message separator.

no external dependencies other than Python 3.4+ and the standard library.

license

released under the terms of the MIT License, Copyright (c) 2016 Myles Hathcock.