mq-bridge-py-basic 0.2.16__cp38-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mq_bridge/__init__.py ADDED
@@ -0,0 +1,17 @@
1
+ from ._mq_bridge import (
2
+ MemoryDrainer,
3
+ Message,
4
+ NonRetryableError,
5
+ Publisher,
6
+ RetryableError,
7
+ Route,
8
+ )
9
+
10
+ __all__ = [
11
+ "MemoryDrainer",
12
+ "Message",
13
+ "NonRetryableError",
14
+ "Publisher",
15
+ "RetryableError",
16
+ "Route",
17
+ ]
mq_bridge/__init__.pyi ADDED
@@ -0,0 +1,108 @@
1
+ from typing import Any, Callable, Dict, List, Mapping, Optional, Union
2
+
3
+ JsonValue = Any
4
+ HandlerResult = Optional[Union["Message", bytes, str, Dict[str, JsonValue], List[JsonValue], int, float, bool]]
5
+
6
+
7
+ class RetryableError(Exception): ...
8
+
9
+
10
+ class NonRetryableError(Exception): ...
11
+
12
+
13
+ class Message:
14
+ def __init__(
15
+ self,
16
+ payload: bytes,
17
+ metadata: Optional[Mapping[str, str]] = ...,
18
+ id: Optional[str] = ...,
19
+ ) -> None: ...
20
+
21
+ @classmethod
22
+ def from_json(
23
+ cls,
24
+ data: JsonValue,
25
+ metadata: Optional[Mapping[str, str]] = ...,
26
+ id: Optional[str] = ...,
27
+ ) -> "Message": ...
28
+
29
+ @property
30
+ def payload(self) -> bytes: ...
31
+
32
+ @property
33
+ def metadata(self) -> Dict[str, str]: ...
34
+
35
+ @property
36
+ def id(self) -> Optional[str]: ...
37
+
38
+ def json(self) -> JsonValue: ...
39
+
40
+ def text(self) -> str: ...
41
+
42
+ def with_json(self, data: JsonValue) -> "Message": ...
43
+
44
+ def with_payload(self, payload: bytes) -> "Message": ...
45
+
46
+
47
+ class Route:
48
+ @classmethod
49
+ def from_yaml(cls, path: str, name: str) -> "Route": ...
50
+
51
+ def with_handler(self, handler: Callable[[Message], HandlerResult]) -> "Route": ...
52
+
53
+ def add_handler(
54
+ self,
55
+ kind: str,
56
+ handler: Callable[[JsonValue], HandlerResult],
57
+ ) -> "Route": ...
58
+
59
+ def run(self) -> None: ...
60
+
61
+ def stop(self) -> None: ...
62
+
63
+
64
+ class MemoryDrainer:
65
+ @classmethod
66
+ def from_topic(
67
+ cls,
68
+ topic: str,
69
+ capacity: int = ...,
70
+ ) -> "MemoryDrainer": ...
71
+
72
+ def drain(
73
+ self,
74
+ count: int,
75
+ timeout: Optional[float] = ...,
76
+ batch_size: int = ...,
77
+ ) -> int: ...
78
+
79
+
80
+ class Publisher:
81
+ @classmethod
82
+ def from_yaml(cls, path: str, name: str) -> "Publisher": ...
83
+
84
+ def send(
85
+ self,
86
+ message: Union[Message, bytes],
87
+ metadata: Optional[Mapping[str, str]] = ...,
88
+ ) -> None: ...
89
+
90
+ def request(
91
+ self,
92
+ message: Union[Message, bytes],
93
+ metadata: Optional[Mapping[str, str]] = ...,
94
+ ) -> Message: ...
95
+
96
+ def send_json(
97
+ self,
98
+ data: JsonValue,
99
+ metadata: Optional[Mapping[str, str]] = ...,
100
+ id: Optional[str] = ...,
101
+ ) -> None: ...
102
+
103
+ def request_json(
104
+ self,
105
+ data: JsonValue,
106
+ metadata: Optional[Mapping[str, str]] = ...,
107
+ id: Optional[str] = ...,
108
+ ) -> Message: ...
Binary file
mq_bridge/py.typed ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: mq-bridge-py-basic
3
+ Version: 0.2.16
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: License :: OSI Approved :: MIT License
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: 3.8
8
+ Classifier: Programming Language :: Python :: 3.9
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Rust
14
+ License-File: LICENSE.python
15
+ Summary: Python bindings for mq-bridge (basic: all-platform messaging set)
16
+ Keywords: messaging,tokio,pyo3,maturin,mq-bridge
17
+ License: MIT
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
20
+ Project-URL: Homepage, https://github.com/marcomq/mq-bridge
21
+ Project-URL: Issues, https://github.com/marcomq/mq-bridge/issues
22
+ Project-URL: Repository, https://github.com/marcomq/mq-bridge
23
+
24
+ # mq-bridge Python bindings
25
+
26
+ Thin Python bindings for the Rust `mq-bridge` core.
27
+
28
+ ## Install
29
+
30
+ Pick exactly one distribution. Both install the same import path: `mq_bridge`.
31
+
32
+ | Package | Install | Includes |
33
+ | :--- | :--- | :--- |
34
+ | Full | `pip install mq-bridge-py` | Basic set plus Kafka, AWS, gRPC, MongoDB, SQLx |
35
+ | Basic | `pip install mq-bridge-py-basic` | HTTP, NATS, MQTT, AMQP, WebSocket, ZeroMQ, middleware |
36
+
37
+ Memory and file endpoints are always present in both packages. Use `mq-bridge-py-basic` when you want the lean all-platform wheel set. Use `mq-bridge-py` when you need Kafka or the heavier non-messaging backends.
38
+
39
+ The public API stays close to mq-bridge itself:
40
+
41
+ - `Route.from_yaml(path, name)` loads one named route
42
+ - `Route.with_handler(...)` attaches a raw `Message` handler, with lazy `json()`/`text()` readers and `with_json()`/`with_payload()` response helpers
43
+ - `Route.add_handler(kind, ...)` uses mq-bridge's `kind` dispatch and delivers decoded JSON
44
+ - `RetryableError` and `NonRetryableError` let Python handlers signal retry intent
45
+ - `Publisher.from_yaml(path, name)` loads one named publisher
46
+ - `Publisher.send_json(...)` and `Publisher.request_json(...)` serialize Python JSON values in Rust
47
+
48
+ The Python surface is synchronous and blocking. Tokio, broker I/O, routing, and batching all stay in Rust.
49
+
50
+ ## Local development
51
+
52
+ `uv` is a good fit here for the Python-side developer workflow, while `maturin` stays the build backend:
53
+
54
+ ```bash
55
+ cd python/mq-bridge-py
56
+ uv sync --group dev --no-install-project
57
+ uv run maturin develop
58
+ uv run pytest -q
59
+ ```
60
+
61
+ Performance smoke tests are skipped by default because they start routes and measure
62
+ local throughput:
63
+
64
+ ```bash
65
+ cd python/mq-bridge-py
66
+ MQ_BRIDGE_RUN_PERF_TESTS=1 uv run pytest -q -m performance
67
+ ```
68
+
69
+ ## Examples
70
+
71
+ Raw message handler:
72
+
73
+ ```bash
74
+ cd python/mq-bridge-py
75
+ uv run python examples/raw_route.py
76
+ ```
77
+
78
+ Kind-based JSON handler:
79
+
80
+ ```bash
81
+ cd python/mq-bridge-py
82
+ uv run python examples/json_route.py
83
+ ```
84
+
85
+ Memory benchmark:
86
+
87
+ ```bash
88
+ cd python/mq-bridge-py
89
+ uv run maturin develop --release
90
+ uv run python examples/bench_memory.py --messages 100000
91
+ ```
92
+
93
+ ## Analysis
94
+
95
+ HTTP comparison benchmark, driven by a native load generator (`wrk`) so the
96
+ client is never the bottleneck. It boots each server itself (mq-bridge in worker
97
+ and direct executor modes, plus FastAPI, Starlette, Sanic, aiohttp, and
98
+ FastStream when installed) and drives each with `wrk`:
99
+
100
+ ```bash
101
+ cd python/mq-bridge-py
102
+ uv run maturin develop --release
103
+ uv sync --group bench # optional Python HTTP peers
104
+ uv run python analysis/bench_http_native.py --connections 1,8,32 --duration 8
105
+ ```
106
+
107
+ Requires `wrk` on `PATH` (`brew install wrk`). The FastStream target compares its
108
+ ASGI custom-route path over Uvicorn; it is not a broker-backed subscriber/publisher
109
+ benchmark. The examples use included sample configs or create temporary configs.
110
+
@@ -0,0 +1,9 @@
1
+ mq_bridge/__init__.py,sha256=c5SSu1m4xFDj0hhoqlh2DkOZuAgDCLUlFIN2ulYx-WU,274
2
+ mq_bridge/__init__.pyi,sha256=JZU0bM8TTEXc29i7lalabbIcvW3oGuTki3y4EdacxeI,2503
3
+ mq_bridge/_mq_bridge.pyd,sha256=bkDnWZ3SaJFYgA9NOA23sRCXzPpdMF8gBdWsM5JiNUY,19311104
4
+ mq_bridge/py.typed,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
5
+ mq_bridge_py_basic-0.2.16.dist-info/METADATA,sha256=hAaX1DMVy1524taDf1xKk6y8WDv231oLaAVQ8D2i8-o,3955
6
+ mq_bridge_py_basic-0.2.16.dist-info/WHEEL,sha256=pFIXPOkq6jL2LlDfuKG9tv96ZyWzqxYbGCGPlqgMguc,95
7
+ mq_bridge_py_basic-0.2.16.dist-info/licenses/LICENSE.python,sha256=j286SjhChHuapJue5Z_zDsrFwKuTZ2cwR2ebkm6SFvo,1094
8
+ mq_bridge_py_basic-0.2.16.dist-info/sboms/mq-bridge-py.cyclonedx.json,sha256=m9S-FCsWBH4JUvjStDl7lcrL9PN21mtZDm_MMlj5-9I,363934
9
+ mq_bridge_py_basic-0.2.16.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.14.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp38-abi3-win_amd64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Marco Mengelkoch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.