Metadata-Version: 2.4
Name: pikados
Version: 0.1.1
Summary: Pika-wrapper
Author: Niek Hoekstra
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Requires-Python: >=3.9
Requires-Dist: pika
Description-Content-Type: text/markdown

from pika.spec import BasicProperties

# Pikados

Pikados is a wrapper around Pika, providing a more asyncio-compatible syntax
for channels and connections.
An effort is made to keep the syntax close to Pika, but simply provide async
functions as many developers expect.

## Usage

Pikados still uses Pika's `AsyncioConnection` internally.
Pika is very clever with its usage of callbacks,
allowing its implementation to start a connection with its' `#!python __init__` implementation.

```python
import asyncio

from pika import URLParameters, BasicProperties
from pika.spec import Basic
from pikados.channel import AsyncChannel
from pikados.connection import connect, AsyncConnection


url = URLParameters("amqp://guest:guest@localhost:5672/%2F")

def on_message(channel: AsyncChannel, method: Basic.Deliver, properties: BasicProperties, body: bytes):
    # Force it to be synchronous (errors will go unseen)
    channel.base.basic_ack(method.delivery_tag)
    # coro = my_handler(channel, method, properties, body)
    # asyncio.get_running_loop().create_task(coro)
    # ... await channel.basic_ack(method.delivery_tag)
    

async def main():
    con: AsyncConnection = await connect(url, 'MyApp')
    channel = await con.channel()
    await channel.basic_qos(prefetch_count=1)
    await channel.basic_consume(
        'queue',
        on_message_callback=on_message,
        auto_ack=False,
    )
    await con.closed.wait()
```

## Docs

Please install using `requirements-docs.txt` and run using `mkdocs serve`.