This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Introduction

Poseur is an RPC framework built upon ZeroMQ sockets, leveraging Python’s asyncio package for high-performance even on the most demanding of services.

Poseur provides an extensible serialization layer, referred to as codecs, used between the RPC endpoints. Two codecs are included: Python’s pickle Module and MessagePack.

As a design decision, Poseur only supports CPython 3.5+. While it may work with older Python versions inadvertently, we do not explicitly support such versions. Use at your own risk!

Other Features Include:

  • Bidirectional RPC. (Servers can call RPC Function on Clients).
  • First Class Exceptions.
  • Heartbeats between RPC endpoints.

Upcoming Features Include:

  • Endpoint Authentication
  • Endpoint Encryption

Warning

Any features or APIs are subject to mass changes before version 1.0 is published. We will attempt to make a few changes as possible, but we can not make any guarantees.

Use with caution!

Installation

Poseur is now available on PyPI:

$ pip install poseur

For supporting the MessagePack codec, also install:

$ pip install msgpack-python

Dependencies

Python 3.5 or greater

Required

  • pyzmq

Extras

  • msgpack-python (For MessagePack Codec Support)

Message Specification

The working message specification can be found in the repository under spec.rst. Until version 1.0 is released, this is subject to change at any time.

Examples

Client to Server RPC

Set up an RPC server and enroll any functions that are to be made available for clients.

import uuid
from poseur import Server, rpc

@rpc.enroll_function
def get_random_uuid_str():
    return str(uuid.uuid4())

server = Server()
server.bind("tcp://127.0.0.1:1234")
server.start()

Set up an RPC client, connect to the server, and call the enrolled function.

import asyncio
from poseur import Client

client = Client("username1")
client.connect("tcp://127.0.0.1:1234")

async def get_and_print():
    value = await client.get_random_uuid_str()
    print(value)

loop = asyncio.get_event_loop()
loop.run_until_complete(get_and_print())

Output

>>> b4c360c2-efba-4853-b8f0-b61557ce6147

Note

Due to using ZeroMQ for the transport mechanism, the order for which a server binds and clients connect is irrelevant. However, there is one caveat when using bidirectional RPC. The client must be connected before the server attempts to make an remote-call to a client, otherwise an exception will be raised.

Using a Different Serialization Codec

To use a different codec, simply set the encoder attribute. By default, PYTHON_PICKLE is used.

from poseur import Client, Server
from poseur.constants import MsgEncoding

# Use Message Pack for all future instances of Client
Client.encoder = MsgEncoding.MESSAGE_PACK
my_client = Client("username1")


# Use Message Pack for this specific instance of Server
my_server = Server()
my_server.encoder = MsgEncoding.MESSAGE_PACK

Heartbeats

Heartbeats are sent by clients to servers, and can contain message bodies that can communicate state between client and server.

By default a client sends empty heartbeats to the server.

The following class attributes (also applicable as instance variables) control the behavior of heartbeats:

Clients

heartbeat_interval:
 The interval for which heartbeats are sent, in seconds. Defaults to 1. Set to 0 to disable heartbeats. If heartbeats are not sent fast enough, a warning will be emitted.
heartbeat_contents:
 Contents of the heartbeat messages. If set to a callable, its return value will be the contents. A callable may be an awaitable/coroutine. Defaults to None.

Servers

heartbeat_callback:
 Callback that is called every time a heartbeat is received. May be an awaitable/coroutine. The callback is called with two arguments, the first a client RPC proxy, the second is contents of the heartbeat message. Defaults to None.
heartbeat_timeout_interval:
 The amount of time, in seconds, that determines if a client has gone offline. The timeout interval begins upon receiving each heartbeat. Set to 0 or None to disable client timeouts. Defaults to 5 seconds.
heartbeat_timeout_callback:
 Callback that is called when a client goes offline, as determined by heartbeat_timeout_interval. May be an awaitable/coroutine. The callback is called with one argument, the client identity/username. If the heartbeat_timeout_interval is disabled, this callback will NOT be called. Defaults to None.
Release History

Release History

0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
poseur-0.3-py35-none-any.whl (15.9 kB) Copy SHA256 Checksum SHA256 py35 Wheel Jun 28, 2016
poseur-0.3.tar.gz (12.5 kB) Copy SHA256 Checksum SHA256 Source Jun 28, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting