Skip to main content

Python AMQP RPC library

Project description


Earlgrey is a python library which provides a convenient way to publish and consume messages between processes using RabbitMQ. It is abstracted to RPC pattern.

How to use

# RPC methods
class Task:
    async def echo(self, value):
        return value

# Client stub
class Stub(MessageQueueStub[Task]):
    TaskType = Task

# Server service
class Service(MessageQueueService[Task]):
    TaskType = Task

async def run():
    route_key = 'any same string between processes'

    client = Stub('localhost', route_key)
    server = Service('localhost', route_key)

    await client.connect()
    await server.connect()

    result = await client.async_task().echo('any value')
    print(result)  # 'any value'

loop = asyncio.get_event_loop()


Actually MessageQueueStub does not need exact Task class which has full implementation of methods. It just needs signature of methods.

# client side.
class Task:
    async def echo(self, value):
        # Just signature. It is okay. Do not need implemetation.
        # But server must have its implementation

Project details

Download files

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

Files for earlgrey, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size earlgrey-0.2.2-py3-none-any.whl (25.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size earlgrey-0.2.2.tar.gz (10.1 kB) File type Source Python version None Upload date Hashes View

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 Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page