ZeroMQ-based JSON-RPC in Python.
Latest commit 3fa076c Feb 16, 2012 @zacharyvoase Bumped to v0.3.1.
Failed to load latest commit information.


ZRPC is a library for building and using simple ZeroMQ-based RPC servers. It uses an ad hoc protocol based on [JSON-RPC 1.0][], with BSON as a transport encoding and support for mixed positional and keyword arguments.

Server Example

from zrpc.server import Registry, Server

# Create a registry and define some methods.
registry = Registry()

def add(*values):
    return sum(values)

def factorial(n):
    return reduce(lambda x, y: x * y, xrange(1, n + 1))

# Create and run a server using the registry.
server = Server('tcp://*:5000', registry)

Client Example

from zrpc.client import Client

c = Client('tcp://')
assert c.add(3, 4) == 7
assert c.factorial(20) == 2432902008176640000

Load Balancer Example

from zrpc.loadbal import LoadBalancer

# The 'proxy' model -- the list of downstream servers is fixed.
lb = LoadBalancer('tcp://', ('tcp://',))

# The 'broker' model -- downstream servers can come and go, but they need
# to specify `connect=True` with an address of 'tcp://' to
# connect to the output port of the balancer.
lb = LoadBalancer('tcp://', 'tcp://')