Metadata-Version: 2.4
Name: pm-park
Version: 0.1.0
Summary: A pure Python pub/sub broker
Author-email: PoWei Chen <a741852963a2000@gmail.com>
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# PM-PARK

PM-PARK (Python Messaging Pub/Sub App Broker) is a pure Python pub/sub broker.

## Features

- TCP pub/sub broker
  - Exact and pattern subscriptions through `fnmatch`
  - `str`, `bytes`, `int`, and `float` message payloads
  - Built-in Python logging
- CLI commands for server and client operations
- Pure Python implementation

## Requirements

- Python `>=3.12`

## CLI

- [CLI Guide](docs/cli_guide.md)
- [Development Docs](docs/development/README.md)

## Python API

- [API Reference](docs/api_reference/README.md)

### Broker service

```python
import time

from pm_park.server import BrokerService

try:
    with BrokerService(host="127.0.0.1", port=6379) as service:
        host, port = service.address
        print(f"Serving on {host}:{port}")
        while service.is_running:
            time.sleep(1.0)
except KeyboardInterrupt:
    pass
```

### Client publish / subscribe

A running broker service is required to execute this example.

```python
from pm_park.client import PMParkClient

messages: list[dict[str, object]] = []

def on_message(message: dict[str, object]) -> None:
    messages.append(message)

with PMParkClient(host="127.0.0.1", port=6379) as sub:
    sub.subscribe("news.sports", handler=on_message)
    sub.psubscribe("news.*", handler=on_message)
    sub.start()

    with PMParkClient(host="127.0.0.1", port=6379) as pub:
        pub.publish("news.sports", b"score")
        pub.publish("news.sports", 42)
        pub.publish("news.sports", 3.14)

    sub.stop()
```

## Development Setup

This section is for developing this repository.
`uv` is used as the primary project management tool.

### Test

- Detailed guide: [tests/README.md](tests/README.md)

```bash
uv run scripts/run_tests.py --unit
uv run scripts/run_tests.py --integration
```

### Build

```bash
uv run scripts/build_wheel.py
```
