Skip to main content

Bidirectionnal RPC Api on top of pyzmq

Project description

https://travis-ci.org/ezeep/pseud.svg?branch=master https://coveralls.io/repos/ezeep/pseud/badge.png Latest Version Code Health

Pythonic bidirectional-rpc API built on top of ØMQ with pluggable encryption, authentication and heartbeating support.

Features

  1. ØMQ transport layer.

  2. All native python types supported (msgpack).

  3. First citizen exceptions.

  4. Bi-bidirectional (server can initiate calls to connected clients).

  5. Encryption based on CURVE.

  6. Pluggable Authentication.

  7. Pluggable Heartbeating.

  8. Pluggable Remote Call Routing.

  9. Works with tornado ioloop or gevent.

  10. Built-in proxy support. A server can delegate the work to another one.

  11. SyncClient (using zmq.REQ) to use within non event based processes. (Heartbeating, Authentication and job execution are not supported with the SyncClient.)

Installation

Dependencies are declared in setup.py and all automatically installed, but, pyzmq might build libzmq from bundled folder OR from your system wide libzmq. In later case you should make sure libzmq has been compiled with libsodium to take advantage of curve security features.

We recommend to install pyzmq with bundled libzmq explicitely if libzmq is already installed on your system.

$ pip install pyzmq --install-option='--zmq=bundled'

Tornado

$ pip install -e .[Tornado]

Gevent

$ pip install -e .[Gevent]

Execution

If both backends are installed, tornado is used by default. To force gevent over tornado, set the environment variable $NO_TORNADO to something.

$ NO_TORNADO=1 python script.py

Preview

The tornado Server

from pseud import Server


server = Server('service')
server.bind('tcp://127.0.0.1:5555')

@server.register_rpc
def hello(name):
    return 'Hello {0}'.format(name)

server.start()  # this will block forever

The tornado Client

# Assume the tornado IOLoop is running
from pseud import Client


client = Client('service', identity='client1', io_loop=loop)
client.connect('tcp://127.0.0.1:5555')

# Assume we are inside a coroutine
response = yield client.hello('Charly')
assert response == 'Hello Charly'

@client.register_rpc(name='draw.me.a.sheep')
def sheep():
    return 'beeeh'

The gevent Client

from pseud import Client


client = Client('service')
client.connect('tcp://127.0.0.1:5555')

assert client.hello('Charly').get() == 'Hello Charly'

The SyncClient

# to use within a non-asynchronous process or in a command interpreter
from pseud import SyncClient


client = SyncClient()
client.connect('tcp://127.0.0.1:5555')

assert client.hello('Charly') == 'Hello Charly'

The Server send a command to the client

# assume we are inside a coroutine
sheep = yield server.send_to('client1').draw.me.a.sheep()
assert sheep == 'beeeh'

Documentation

Pseud on Readthedocs

Project details


Download files

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

Source Distribution

pseud-0.0.5.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

pseud-0.0.5-py2-none-any.whl (17.8 kB view details)

Uploaded Python 2

File details

Details for the file pseud-0.0.5.tar.gz.

File metadata

  • Download URL: pseud-0.0.5.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pseud-0.0.5.tar.gz
Algorithm Hash digest
SHA256 35206df3385e79592ba6d9219670b61729612d704127ec7dd8b9b49f4c8a047d
MD5 d94b032796fcd31f4a97e28c4f76de98
BLAKE2b-256 285a724367b7794ff6bf7bc164378a26949b6fd7e55567f6a8c463e6c7f7f5bd

See more details on using hashes here.

File details

Details for the file pseud-0.0.5-py2-none-any.whl.

File metadata

File hashes

Hashes for pseud-0.0.5-py2-none-any.whl
Algorithm Hash digest
SHA256 b6d61029803f08c51e0191ac314b406d0108f1fb98975d5ad6dbc29511b4b24d
MD5 d37fcfaf06f3c720d4a21e05d59c78f2
BLAKE2b-256 8e92841842810fc4c48571e11a10fde8673bf45b8f412cc9506fdbbd019271a1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page