Metadata-Version: 2.4
Name: pico-rabbitmq
Version: 0.1.1
Summary: RabbitMQ pub-sub for the Pico ecosystem: @consumer methods and @publisher clients over aio-pika.
Author-email: David Perez Cabrera <dperezcabrera@gmail.com>
License: MIT License
        
        Copyright (c) 2025 David Pérez Cabrera
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/dperezcabrera/pico-rabbitmq
Project-URL: Documentation, https://dperezcabrera.github.io/pico-rabbitmq/
Project-URL: Repository, https://github.com/dperezcabrera/pico-rabbitmq
Project-URL: Changelog, https://github.com/dperezcabrera/pico-rabbitmq/blob/main/CHANGELOG.md
Project-URL: Issue Tracker, https://github.com/dperezcabrera/pico-rabbitmq/issues
Keywords: rabbitmq,amqp,messaging,pubsub,aio-pika,ioc,spring boot
Classifier: Development Status :: 4 - Beta
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pico-ioc>=2.2.0
Requires-Dist: aio-pika>=9
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-cov>=5; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Dynamic: license-file

# pico-rabbitmq

[![PyPI](https://img.shields.io/pypi/v/pico-rabbitmq.svg)](https://pypi.org/project/pico-rabbitmq/)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/dperezcabrera/pico-rabbitmq)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![CI (tox matrix)](https://github.com/dperezcabrera/pico-rabbitmq/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/dperezcabrera/pico-rabbitmq/branch/main/graph/badge.svg)](https://codecov.io/gh/dperezcabrera/pico-rabbitmq)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dperezcabrera_pico-rabbitmq&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-rabbitmq)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=dperezcabrera_pico-rabbitmq&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-rabbitmq)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=dperezcabrera_pico-rabbitmq&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=dperezcabrera_pico-rabbitmq)
[![PyPI Downloads](https://img.shields.io/pypi/dm/pico-rabbitmq)](https://pypi.org/project/pico-rabbitmq/)
[![Docs](https://img.shields.io/badge/Docs-pico--rabbitmq-blue?style=flat&logo=readthedocs&logoColor=white)](https://dperezcabrera.github.io/pico-rabbitmq/)
[![Interactive Lab](https://img.shields.io/badge/Learn-online-green?style=flat&logo=python&logoColor=white)](https://dperezcabrera.github.io/pico-learn/)

RabbitMQ pub-sub for the [pico ecosystem](https://github.com/dperezcabrera/pico-ioc): `@consumer` methods and declarative `@publisher` clients over aio-pika. Covers what pico-celery does not: events, fan-out, topic routing.

## Installation

```bash
pip install pico-rabbitmq
```

## Quick start

```yaml
rabbitmq:
  url: amqp://guest:guest@rabbit.internal/
```

Consume — a component method per queue, JSON body decoded for you:

```python
from pico_ioc import component
from pico_rabbitmq import consumer

@component
class OrderProjections:
    @consumer("orders-projection", exchange="events", routing_key="orders.*")
    async def on_order_event(self, message: dict):
        ...
```

Publish — stubs, like a pico-httpx client:

```python
from pico_rabbitmq import publisher, publish

@publisher
class OrderEvents:
    @publish(exchange="events", routing_key="orders.created")
    def order_created(self, message): ...
```

Semantics:

- Consumers and publishers run on a dedicated background loop — works in sync scripts, FastAPI apps and workers alike, no lifespan wiring.
- Each message resolves its component through the container (prototype scope = fresh instance per message).
- Ack on success; on exception the message is logged and rejected **without requeue** (configure a dead-letter exchange to keep failures).
- Sync publish stubs block until the broker confirms; async stubs await it.
- Queues and named exchanges are declared durable; the connection closes on container shutdown.

## Documentation

Full documentation: https://dperezcabrera.github.io/pico-rabbitmq/

## AI Coding Skills

Install [Claude Code](https://code.claude.com) or [OpenAI Codex](https://openai.com/index/introducing-codex/) skills for AI-assisted development with pico-rabbitmq:

```bash
curl -sL https://raw.githubusercontent.com/dperezcabrera/pico-skills/main/install.sh | bash
```

The `pico-conventions` skill teaches the assistant this module's API surface and invariants; `/add-component` and `/add-tests` scaffold components and tests that use it.

## License

MIT
