nats-extra
Core NATS extensions. The first utility is request-many, a streaming
request/reply and scatter-gather pattern matching nats-extra in orbit.rs.
Install
pip install nats-extra
Usage
import nats.extra
from nats.client import connect
nc = await connect("nats://localhost:4222")
responses = await nats.extra.request_many(
nc,
"services.ping",
b"ping",
stall_wait=0.25, # stop after 250 ms without another response
)
async for response in responses:
print(response.data)
print(responses.termination_reason)
Request streams can terminate on max_messages, max_wait, stall_wait, a
sentinel predicate, a no-responders status, or subscription closure. The reason
is available as responses.termination_reason.
The orbit.rs-style builder is also available:
responses = await (
nats.extra.RequestMany(nc)
.max_messages(10)
.stall_wait(0.25)
.sentinel(lambda message: message.data == b"done")
.send("services.work", b"start")
)
Natural termination unsubscribes automatically. When abandoning a response
stream early, call await responses.aclose() or use it as an async context
manager.
License
Apache 2.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nats_extra-0.1.0.tar.gz.
File metadata
- Download URL: nats_extra-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fb0fbbf35e187dccd088a62780700955bbb5712fae385f2bd39ccd6189a08c7
|
|
| MD5 |
18793bfa009589f63a659f251779101d
|
|
| BLAKE2b-256 |
a38493c0244bd341f07938dc37df7f72dd44804dbba5493e97b3eaa80f681b80
|
File details
Details for the file nats_extra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nats_extra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa03a862667a036d2deaf62cb1607e2a1ca57faaa879ee74145812b27f02be14
|
|
| MD5 |
9b51b613078a1f87e362f69db24dd7a4
|
|
| BLAKE2b-256 |
5d908a7debff3f5d6044de4e20d585c099bb9b50b83e3b1392e8bf2a52dcef88
|