pamoja-loopback 0.1.17__py3-none-any.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.
@@ -0,0 +1,16 @@
1
+ """Idiomatic loopback-broker facade.
2
+
3
+ An in-process broker: publish on one link, receive on another, with no broker
4
+ process, no network, and no hardware. It is what makes a message flow testable
5
+ from a unit test rather than only from a deployment.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from pamoja._native import LoopbackBroker, LoopbackTransport, Message
11
+
12
+ __all__ = [
13
+ "LoopbackBroker",
14
+ "LoopbackTransport",
15
+ "Message",
16
+ ]
File without changes
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.5
2
+ Name: pamoja-loopback
3
+ Version: 0.1.17
4
+ Summary: An in-process transport with topic matching and a fault injector, for testing with no broker.
5
+ Project-URL: Repository, https://github.com/molexxxx/pamoja
6
+ Project-URL: Documentation, https://pamoja.molex.cloud/docs/guides/loopback.html
7
+ Author: molexxxx
8
+ License: MIT
9
+ License-File: LICENSE-MIT
10
+ Keywords: iot,loopback,pamoja,robotics
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: pamoja-native==0.1.17
17
+ Description-Content-Type: text/markdown
18
+
19
+ # pamoja-loopback
20
+
21
+ An in-process transport with topic matching and a fault injector, for testing with no broker. One capability of [pamoja](https://github.com/molexxxx/pamoja), one memory-safe Rust core with bindings for TypeScript, Python, and C#.
22
+
23
+ [![API reference](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-api.svg)](https://pamoja.molex.cloud/docs/reference/python/pamoja/loopback.html)
24
+ [![read the guide](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-guide.svg)](https://pamoja.molex.cloud/docs/guides/loopback.html)
25
+ [![documentation](https://raw.githubusercontent.com/molexxxx/pamoja/main/.github/badges/btn-docs.svg)](https://pamoja.molex.cloud/docs/)
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pip install pamoja-loopback
31
+ ```
32
+
33
+ ```python
34
+ from pamoja import loopback
35
+ ```
36
+
37
+ This pulls in `pamoja-native`, the compiled engine. `pip install pamoja` is the whole framework in one package.
38
+
39
+ ## Example
40
+
41
+ The script the test suite runs, spliced here as it ran.
42
+
43
+ From [`bindings/python/guides/loopback.py`](https://github.com/molexxxx/pamoja/blob/main/bindings/python/guides/loopback.py):
44
+
45
+ ```python
46
+ import asyncio
47
+
48
+ from pamoja.core import PamojaError
49
+ from pamoja.loopback import LoopbackBroker
50
+
51
+
52
+ async def main() -> None:
53
+ # One broker and two links off it, all in this process. Nothing binds a port and
54
+ # nothing has to be running for the traffic below to flow, which is what makes this
55
+ # the link to develop a node against before it has a real one.
56
+ broker = LoopbackBroker()
57
+ publisher = broker.link()
58
+ subscriber = broker.link()
59
+ await publisher.connect()
60
+ await subscriber.connect()
61
+
62
+ # A `+` stands for exactly one level, so this takes the mixer's temperature but not the
63
+ # raw reading a level below it.
64
+ await subscriber.subscribe("line/+/temp")
65
+ await publisher.send("line/mixer/temp/raw", b"2150")
66
+ await publisher.send("line/mixer/temp", b"21.5")
67
+
68
+ message = await subscriber.recv()
69
+ print(f"line/+/temp took {message.payload.decode()} from {message.topic}")
70
+
71
+ # A `#` covers every level that remains, so a second link takes the whole subtree,
72
+ # including the reading the single-level filter passed over.
73
+ watcher = broker.link()
74
+ await watcher.connect()
75
+ await watcher.subscribe("line/#")
76
+ await publisher.send("line/mixer/temp/raw", b"2150")
77
+
78
+ deep = await watcher.recv()
79
+ print(f"line/# took {deep.payload.decode()} from {deep.topic}")
80
+
81
+ # A link that has been disconnected reports the failure instead of dropping the
82
+ # reading, which is the case a test wants to reach without unplugging anything.
83
+ await publisher.disconnect()
84
+ try:
85
+ await publisher.send("line/mixer/temp", b"21.6")
86
+ print("a disconnected link took a reading, which should never happen")
87
+ except PamojaError as error:
88
+ print(f"disconnected refused the reading: {error}")
89
+
90
+ return message, deep
91
+
92
+
93
+ message, deep = asyncio.run(main())
94
+ ```
95
+
96
+ ## The same capability in every language
97
+
98
+ | Language | Package | Reference |
99
+ | --- | --- | --- |
100
+ | Rust | [`pamoja-loopback`](https://crates.io/crates/pamoja-loopback) | [reference](https://pamoja.molex.cloud/docs/reference/rust/pamoja_loopback/index.html), [docs.rs](https://docs.rs/pamoja-loopback), [install](https://pamoja.molex.cloud/docs/reference/rust.html#rust-loopback) |
101
+ | TypeScript | [`@pamoja/loopback`](https://www.npmjs.com/package/@pamoja/loopback) | [reference](https://pamoja.molex.cloud/docs/reference/node/modules/_pamoja_loopback.html), [install](https://pamoja.molex.cloud/docs/reference/node.html#node-loopback) |
102
+ | Python | [`pamoja-loopback`](https://pypi.org/project/pamoja-loopback/) | [reference](https://pamoja.molex.cloud/docs/reference/python/pamoja/loopback.html), [install](https://pamoja.molex.cloud/docs/reference/python.html#python-loopback) |
103
+ | C# | [`Pamoja.Loopback`](https://www.nuget.org/packages/Pamoja.Loopback) | [reference](https://pamoja.molex.cloud/docs/reference/dotnet/api/Pamoja.Loopback.html), [install](https://pamoja.molex.cloud/docs/reference/dotnet.html#dotnet-loopback) |
104
+
105
+ ## Documentation
106
+
107
+ - [`pamoja.loopback` reference](https://pamoja.molex.cloud/docs/reference/python/pamoja/loopback.html), every class and function in this module.
108
+ - [The Loopback guide](https://pamoja.molex.cloud/docs/guides/loopback.html), with the same example in Rust, TypeScript, and C#.
109
+ - [Every capability](https://pamoja.molex.cloud/docs/), and the [install page](https://pamoja.molex.cloud/docs/install.html).
110
+
111
+ ## License
112
+
113
+ MIT
@@ -0,0 +1,6 @@
1
+ pamoja/loopback/__init__.py,sha256=sU_MOsygwuCfPD6Opcc4HKMBBoCoKyb0Y5RYjW5oQvc,436
2
+ pamoja/loopback/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pamoja_loopback-0.1.17.dist-info/METADATA,sha256=r91YYK8Mm4HcLbnzebIYtlrBfolF0fd0DI1yL_4zT4M,5208
4
+ pamoja_loopback-0.1.17.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
5
+ pamoja_loopback-0.1.17.dist-info/licenses/LICENSE-MIT,sha256=f6NfyVO02r56R7vpDizB94FR7Xmntgl0QVQcJ-Mhmlg,1072
6
+ pamoja_loopback-0.1.17.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anthony Wiedman
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.