cangling-broker (Python)
Producer and consumer for cangling-broker. Same contract as the Java client: AcceptMessages to publish, Subscribe to consume, optional Register metadata, CL_BROKER_AUTH_TOKEN on every RPC.
Install
pip install cangling-broker
From this tree:
pip install -e python
Use
from cangling_broker import SatwayClient, SubscribeOptions
with SatwayClient.connect("127.0.0.1:7500", "change-me") as client:
client.send("cangling-test", "hello")
with client.subscribe(
SubscribeOptions(topic="cangling-test", name="worker-1"),
lambda message: print(message.id, message.payload),
):
...
SatwayClient.connect(broker) also reads CL_BROKER_AUTH_TOKEN from the environment.
Batch-set topic delivery (single = one consumer, broadcast = every live stream) and persistence (persistent = queue for later, ephemeral = drop if nobody is subscribed):
from cangling_broker import TopicConfig
client.configure_topics([
TopicConfig("jobs", "single"),
TopicConfig("alerts", "broadcast"),
TopicConfig("live-events", "broadcast", "ephemeral"),
])
print(client.list_topics())
Existing Kafka senders can keep send(topic, value) / flush():
# from kafka import KafkaProducer
from cangling_broker import KafkaProducer
producer = KafkaProducer(bootstrap_servers="127.0.0.1:7500")
producer.send(topic, msg)
producer.flush()
# consume
python python/examples/consumer.py --broker 127.0.0.1:7500 --topic cangling-test --name py-s0 --token change-me
# produce
python python/examples/producer.py --broker 127.0.0.1:7500 --topic cangling-test --text hello --count 1 --token change-me
Publish to PyPI
CI on tag v* builds the package and uploads with pypa/gh-action-pypi-publish. Set repository secret PYPI_API_TOKEN.
cd python
python generate_proto.py
python -m build
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 cangling_broker-0.1.35.tar.gz.
File metadata
- Download URL: cangling_broker-0.1.35.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faf83540049cc82c20bc24246dbfbb8fa0911633bd1ca6130f244d15ff079756
|
|
| MD5 |
0f7556c6ce5669f0d1f35ccb2851ccff
|
|
| BLAKE2b-256 |
7a491b2155d78f0533f8e9c2d007d261526bb429206624d361c8a132b40923a3
|
File details
Details for the file cangling_broker-0.1.35-py3-none-any.whl.
File metadata
- Download URL: cangling_broker-0.1.35-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59069217b57e426baa4101008c4f54e01508749c0b73b38e6aa666d8ab0edc99
|
|
| MD5 |
96be05b47cf77b55d182d0d75dc4bfce
|
|
| BLAKE2b-256 |
097cf3416b46064f808c687cfd7bee6e9fae8aacfdacc4798d09366ca062f21e
|