Python AMQP RPC library
Project description
Earlgrey
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:
@message_queue_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()
loop.run_until_complete(run())
Caution
Actually MessageQueueStub
does not need exact Task
class which has full implementation of methods. It just needs signature of methods.
# client side.
class Task:
@message_queue_task
async def echo(self, value):
# Just signature. It is okay. Do not need implemetation.
# But server must have its implementation
pass
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
earlgrey-0.2.2.tar.gz
(10.1 kB
view details)
Built Distribution
earlgrey-0.2.2-py3-none-any.whl
(25.7 kB
view details)
File details
Details for the file earlgrey-0.2.2.tar.gz
.
File metadata
- Download URL: earlgrey-0.2.2.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e53f1c02281838990f472a4cd84c88ec2476aa1fbe0c1fd02da609d8f2c286e |
|
MD5 | 85b9b77cf62e8a8844e57b45bb1d2144 |
|
BLAKE2b-256 | aa3fc9daac728ac906d80af746529bf4e9b1c555a492394bb1a5d73618ddbf5f |
File details
Details for the file earlgrey-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: earlgrey-0.2.2-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0982e362820c04820d3af2fdff3b09c487e6ac4b11d788f15293d7b8e30f04a5 |
|
MD5 | 2fe1a4b19c865d410c8c9ef53e228fa5 |
|
BLAKE2b-256 | bc981d0168fd35727892fe55e63300ff57fcf289707658c3453a3f3bd4c3bed7 |