Embedded Apache Pulsar-compatible broker for local development
Project description
Pulsar Lite
Pulsar Lite is a lightweight local broker that implements the core Apache Pulsar binary protocol. This package ships a small Python helper that can start and manage a local broker process, so you can use Pulsar topic names and the official Pulsar Python client with a single local file path.
It is designed for fast local feedback, not as a production replacement for an Apache Pulsar cluster. Use Apache Pulsar for production workloads that require multi-broker scheduling, replication, capacity management, tenant isolation, or operational SLAs.
Why use the Python helper
Many applications only need a local broker to validate the messaging path: producers, consumers, subscriptions, flow control, failover, and key-based routing. Setting up a full Pulsar deployment can be more expensive than the test or prototype itself.
pulsar-lite keeps the client-facing API close to Pulsar while removing the
local setup cost:
- Start a local broker by passing a file path, no manual process management.
- Connect with the official
pulsar-client(installed automatically). - Use Pulsar topic names such as
persistent://...andnon-persistent://.... - Exercise Shared, Failover, Exclusive, and KeyShared subscription behavior.
Installation
pip install pulsar-lite
The package declares pulsar-client>=3.0.0 as a runtime dependency, so the
official Pulsar Python client is installed automatically.
Platform wheels include a prebuilt broker binary. If no wheel matches your platform, see the build from source section.
Quick start: embedded mode
Pass a local file path and the helper starts a broker process for you:
import pulsar
from pulsar_lite import PulsarClient
topic = "non-persistent://public/default/quick-start"
with PulsarClient("./demo.db") as client:
consumer = client.subscribe(
topic,
"quick-start-sub",
consumer_type=pulsar.ConsumerType.Shared,
)
producer = client.create_producer(topic)
producer.send(b"hello from pulsar lite")
message = consumer.receive(timeout_millis=5000)
print(message.data().decode("utf-8"))
consumer.acknowledge(message)
When the PulsarClient context exits, the embedded broker process is stopped
automatically (reference counted, so multiple clients on the same path share
one broker).
Quick start: remote mode
If you already have a broker running (locally or remotely), pass a pulsar://
URI instead and the helper acts as a thin wrapper over pulsar.Client:
import pulsar
from pulsar_lite import PulsarClient
with PulsarClient("pulsar://localhost:6650") as client:
producer = client.create_producer("non-persistent://public/default/events")
producer.send(b"event-1")
You can also skip the helper entirely and use the official client directly, since the broker speaks the standard Pulsar binary protocol:
import pulsar
client = pulsar.Client("pulsar://localhost:6650")
Explicit broker lifecycle
For cases where you want to start the broker and then connect with the official
client (or multiple clients), use start_broker:
import pulsar
from pulsar_lite import start_broker
with start_broker("./demo.db") as broker:
client = pulsar.Client(broker.url)
# ... use the official client against broker.url ...
client.close()
API
PulsarClient(uri, **kwargs)
uri:- A local file path (e.g.
"./demo.db") starts an embedded broker. - A
pulsar://orpulsar+ssl://URI connects to an existing broker.
- A local file path (e.g.
**kwargsare forwarded topulsar.Client.- Any attribute access not defined on
PulsarClientitself is forwarded to the underlyingpulsar.Client, so the standard Pulsar API (create_producer,subscribe,get_topic_partitions, ...) is fully available. - Supports
withstatements and auto-closes the embedded broker on exit.
Properties:
| Property | Description |
|---|---|
is_embedded |
True when the helper started a local broker. |
db_path |
The absolute local file path (embedded mode only). |
pulsar_url |
The pulsar://localhost:<port> URL the client connects to. |
start_broker(db_path) -> BrokerHandle
Starts (or reuses) an embedded broker for the given path and returns a
BrokerHandle with .url, .port, and a .stop() method. Use it as a
context manager for automatic cleanup.
Topic names and subscription modes
Pulsar Lite accepts standard Pulsar topic URIs:
persistent://public/default/my-topic
non-persistent://public/default/my-topic
Use non-persistent://... for live event dispatch where slow or disconnected
consumers should not create a durable backlog. Use persistent://... when a
test requires stored entries, cursor replay, or acknowledgements across restart
(requires a broker binary built with RocksDB storage support).
Supported subscription modes:
| Mode | Summary |
|---|---|
| Exclusive | One active consumer; additional consumers are rejected. |
| Failover | One active consumer with standby takeover. |
| Shared | Messages are distributed across available consumers. |
| KeyShared | Messages with the same key are routed to the same consumer. |
Binary discovery
The helper looks for the bundled broker binary in this order:
- The
pulsar_lite/bin/directory shipped inside the wheel. - The
PULSAR_LITE_BINARYenvironment variable. - The Rust release output at
rust/target/release/pulsar-lite(development mode). - The system
PATH. - Common install locations such as
/usr/local/bin/pulsar-lite.
If you build the broker yourself, point PULSAR_LITE_BINARY at the resulting
binary instead of reinstalling the package.
Building the broker from source
If no prebuilt wheel matches your platform, build the broker from source and
let the helper discover it via PULSAR_LITE_BINARY:
git clone https://github.com/ascentstream/pulsar-lite.git
cd pulsar-lite/rust
cargo build --release # core build
cargo build --release --features rocksdb-storage # with persistent storage
Then install the Python package and point it at your binary:
cd ../python
pip install -e .
export PULSAR_LITE_BINARY=$(pwd)/../rust/target/release/pulsar-lite
Links
- Source: https://github.com/ascentstream/pulsar-lite
- Issues: https://github.com/ascentstream/pulsar-lite/issues
- Full documentation: https://github.com/ascentstream/pulsar-lite#readme
Project boundaries
Pulsar Lite intentionally does not provide:
- Multi-broker coordination or load balancing.
- Cross-cluster replication.
- Production-grade authorization or tenant governance.
- BookKeeper compatibility.
- Production durability or availability guarantees.
The project is useful for local development and compatibility testing, but production deployments should use Apache Pulsar.
License
Pulsar Lite is licensed under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 pulsar_lite-0.1.0.tar.gz.
File metadata
- Download URL: pulsar_lite-0.1.0.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd0603e68a5e001d63d72401cc08b4ba3a8119924b424d869a795187e8d0e132
|
|
| MD5 |
49adf1bf4b3a613543318b60e336a7ee
|
|
| BLAKE2b-256 |
5f31afd7418dd64cd181d45a3a8215add6b9db7ee7b2a831b829e1ffba096212
|
File details
Details for the file pulsar_lite-0.1.0-py3-none-win_amd64.whl.
File metadata
- Download URL: pulsar_lite-0.1.0-py3-none-win_amd64.whl
- Upload date:
- Size: 3.5 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9fcd8875b1827cc246935ad5bd19f395feea0b72b73b4caf1b1d8aa6bc78e1
|
|
| MD5 |
0426532fa710291803c9df57ba5ea8c1
|
|
| BLAKE2b-256 |
e25c1e81c82a630ff70f06003cfc4253ded88518521fac6e228a9e4a985f15ed
|
File details
Details for the file pulsar_lite-0.1.0-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: pulsar_lite-0.1.0-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19fc78f71b831756fa5c901d28bea3a37a5a6928a5ff42025e105fd9292afc35
|
|
| MD5 |
cb4611b4872f0cf75ceb1145ccc1422c
|
|
| BLAKE2b-256 |
ef2f8c29ba069528a898094feceff3f5c4475c727c5666d9f98fce9bc0d02fa4
|
File details
Details for the file pulsar_lite-0.1.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: pulsar_lite-0.1.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81abc76eb7fafe81d7e7fea4edf1ea6794559b34d64364d120a0eb8012325ee5
|
|
| MD5 |
f92304faa451b6ea3b9517e898381c9b
|
|
| BLAKE2b-256 |
4c41729595809f661d251ba748e49f31b881ec3f5419c200d90a7bce3ae2718f
|