Metadata-Version: 2.1
Name: earlgrey
Version: 0.2.2
Summary: Python AMQP RPC library
Home-page: https://github.com/icon-project/earlgrey
Author: ICON foundation
License: Apache License 2.0
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/markdown
Requires-Dist: aio-pika (~=6.7.1)
Requires-Dist: pika (~=1.1.0)
Provides-Extra: test
Requires-Dist: pytest (~=5.4.2) ; extra == 'test'
Requires-Dist: mock (~=4.0.1) ; extra == 'test'

# 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
```python
# 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.
```python
# 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
```


