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
Release files for cangling-broker 0.1.57
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cangling_broker-0.1.57.tar.gz | 15.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cangling_broker-0.1.57-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.4 kB
Release files / cangling_broker-0.1.57.tar.gz
| Download URL | cangling_broker-0.1.57.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6459a2f4fe61516adbfda5da65df4ae06bac467bc2ca9418d8985fe8388d0fc
|
|
BLAKE2b-256 checksum How to use checksums |
a19b4d86aaf05a53fee827eecec1af758f19cc488b970dfad8dc5192f36e28ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / cangling_broker-0.1.57-py3-none-any.whl
| Download URL | cangling_broker-0.1.57-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b343b7f2441ad9dbeb08275760489703351314e3c514b2f86912a7a1691322f
|
|
BLAKE2b-256 checksum How to use checksums |
9073ade22fb49976c4c19404195570af34e9abfe3e2949b4c33b6b803e6a7a5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|