M7: PLAN.md records the checks as done, and the bug they found (#57)

M7's section now says where its checks stand: what the conformance suite and
checklist (tests/conformance/README.md) hold, tests/PORTING.md's counts, why
the tests in scope that it doesn't cover have no counterpart, and the one bug
the checks found. Once the controller moves to another broker, a Stream
consumer whose client holds the topic's layout watch for something else too
registers again with the old controller (C7's known gap), which an ignored test
pins until it is fixed. Only documentation changes.
1 file changed
tree: 15e7023bcec84f1e391b4cefb529103c988e97c1
  1. .github/
  2. build-support/
  3. checks/
  4. crates/
  5. docs/
  6. tests/
  7. tools/
  8. xtask/
  9. .asf.yaml
  10. .gitignore
  11. .rat-excludes
  12. Cargo.lock
  13. Cargo.toml
  14. deny.toml
  15. DESIGN.md
  16. LICENSE
  17. NOTICE
  18. PLAN.md
  19. README.md
  20. RELEASE.md
  21. rustfmt.toml
README.md

Apache Pulsar Rust client

A Rust client for Apache Pulsar scalable topics, built from the Scalable Topics client specification on the compio runtime.

Status: the first release, 0.1.0, is being prepared. Producers publish to scalable topics, keeping per-key order across segment splits and merges, and to regular persistent:// topics through the migration bridge. Queue consumers read every segment of a topic, following its splits and merges, and acknowledge each message. Stream consumers read the segments the topic‘s controller assigns them, each key in order, share segments by entry bucket when they outnumber them, and acknowledge cumulatively. Checkpoint consumers read every segment, parents before their children, or as members of a group the segments the controller assigns them, and resume from checkpoints the application keeps, in the Java client’s bytes. All work in the thread-safe, local and blocking APIs, with token and mTLS authentication, directly or through a proxy. Producers batch messages by entry bucket and compress them, as Java‘s do. Messages carry the Java client’s schemas: bytes, string, the primitive types, key/value, JSON, Avro and Protobuf, and generic records. The design is in DESIGN.md, the milestones in PLAN.md.

let client = PulsarClient::builder().service_url("pulsar://localhost:6650").build().await?;
let producer = client.new_producer(Schema::string()).topic("topic://public/default/orders").create().await?;
let id = producer.new_message().key("user-42").value("hello".to_string()).send().await?;
producer.close().await?;

let consumer = client.new_queue_consumer(Schema::string())
    .topic("topic://public/default/orders")
    .subscription_name("workers")
    .subscribe().await?;
let message = consumer.receive().await?;
consumer.acknowledge(message.id()).await?;
client.close().await?;

Conformance

Each release states the version of the Scalable Topics client specification it conforms to, and which of the specification's optional capabilities it implements, in its release notes. The client conforms to version 1.0. It implements the required core, C1 to C15 (conformance §2), and these of the optional capabilities (§3):

CapabilityImplemented
Entry-bucketing, producer sideYes: each batch holds one entry bucket's messages, and each entry is stamped with its bucket hashes.
Migration bridgeYes: persistent:// topics, partitioned or not, and short topic names.
Chunking, compression, custom batchingCompression: LZ4, ZLIB, ZSTD and Snappy. No chunking, and no custom batching.
TransactionsNo.
Namespace subscriptionNo.
Dead-letterNo.
End-to-end encryptionNo.

Layout

PathWhat it is
crates/apache-pulsarThe client: producers, Queue, Stream and Checkpoint consumers, layout watches, connections, the pool, lookup, authentication, TLS, the memory limit, and the thread-safe, local and blocking APIs.
crates/apache-pulsar/examplesRunnable examples: a producer, the Queue, Stream and Checkpoint consumers, the local and blocking APIs, schemas, TLS and token authentication, and pipelined sends.
crates/apache-pulsar-protocolThe sans-IO protocol core: generated protobuf code, framing, the connection, producer and consumer state machines, entry decoding, layouts and routing, message ids. Internal; not a stable API.
crates/apache-pulsar-testkitThe simulated broker and cluster, and the deterministic tests of the protocol state machines. Not published.
checks/Milestone 0 checks: compio behavior, and the handshake against a real broker.
tools/java-vectorsGenerates test vectors from the Java client.
xtaskRepository tasks: protobuf code generation.

Examples

crates/apache-pulsar/examples has one example for each part of the API. They run against a broker on this machine, or the one PULSAR_URL names. Start a standalone broker that advertises localhost, and once it is up, which takes a few seconds, run one:

docker run -d --rm --name pulsar -p 6650:6650 -p 8080:8080 apachepulsar/pulsar:5.0.1 bash -c "echo advertisedAddress=localhost >> conf/standalone.conf && exec bin/pulsar standalone"
cargo run --example producer
ExampleWhat it shows
producerKeyed messages with properties, a flush and a close, on the default API from a Tokio runtime.
queue_consumerA Shared subscription on every segment: each message acknowledged, one negatively and delivered again.
stream_consumerSegments the controller assigns, each key in order, and cumulative acknowledgments.
checkpoint_consumerNo subscription: a checkpoint kept in a file, and a second run that reads on from it.
localThe local API: a client per thread, each on its own compio event loop.
blockingThe blocking API, without an async runtime.
schemasJSON, Avro and key/value schemas for a struct, and generic records.
authenticationTLS with a trusted CA, and a token, a token file or a client certificate.
pipeliningMany sends in flight, in order, with buffered, FuturesOrdered and join_all.

Building and testing

Building needs Rust 1.95 or later, and a C compiler for the ZSTD codec.

cargo test --workspace

The generated protobuf code is committed, so building needs no protoc. After changing the vendored crates/apache-pulsar-protocol/proto/PulsarApi.proto, regenerate it (needs protoc 33.1, the version CI checks with):

cargo run -p xtask -- codegen

The handshake against a real broker:

docker run -d --rm --name pulsar -p 6650:6650 -p 8080:8080 apachepulsar/pulsar:5.0.1 bin/pulsar standalone
cargo run -p first-contact -- 127.0.0.1:6650

The integration tests start a broker and a proxy in Docker, with TLS, token and mTLS authentication, and remove them when they finish. A Java tool they run in the broker container is compiled in an eclipse-temurin JDK container. cargo test skips them; they need Docker running:

cargo test -p apache-pulsar --test integration

License

Apache License 2.0.