Repository navigation
M7 audit, part 2: examples - #44
Merged
Merged
Conversation
The second part of M7's audit: examples, one for each part of the API, in crates/apache-pulsar/examples. Each runs against a broker on this machine, or the one PULSAR_URL names. - producer: keyed messages with properties, a flush and a close, on the default API from a Tokio runtime. - queue_consumer: a Shared subscription on every segment, each message acknowledged, one negatively and delivered again. - stream_consumer: the segments the controller assigns, and cumulative acknowledgments. - checkpoint_consumer: a checkpoint kept in a file, and a second run that reads on from it. - local: a client per thread, each on its own compio event loop. - blocking: the blocking API, without an async runtime. - schemas: JSON, Avro and key/value schemas for a struct, and generic records; it takes the json and avro features. - authentication: TLS with a trusted CA, and a token, a token file or a client certificate. - pipelining: many sends in flight, in order, with buffered, FuturesOrdered and join_all, the patterns send's rustdoc recommends. Dev-dependencies: tokio and futures, both in the lock already through testcontainers. CI's clippy --all-targets and cargo test build the examples; cargo-llvm-cov leaves them out of the coverage report. The README lists them, with the command for a standalone broker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The second part of M7's audit (
PLAN.md, M7): examples, which the repository didn't have. The error model is #38;the rustdoc follows in its own pull request.
What it adds
crates/apache-pulsar/examples, one example for each part of the API. Each runs against a broker on this machine,or the one
PULSAR_URLnames, and takes another topic as its first argument.producerqueue_consumerstream_consumercheckpoint_consumerlocalblockingschemasauthenticationpipeliningbuffered,FuturesOrderedandjoin_all.localruns its own compioloops, and
blockingnone.pipelininguses the three patterns thatsend's rustdoc recommends, and thatpipelining_combinators_keep_send_order(M2) checks keep send order, and says what loses the order: a send spawnedas a task of its own, and a send future dropped after its first poll.
schemastakes thejsonandavrofeatures, on by default, as itsrequired-features.authenticationtakes its setup from the environment. Its token file is read again for each connection, by thestandard library, as a provider's future runs on the client's event loop, not on Tokio.
Dev-dependencies:
tokio, for#[tokio::main], andfutures, for the combinators. Both were in the lock already,through testcontainers, so
Cargo.lockonly gains the two edges. The README lists the examples, with the command fora standalone broker that advertises
localhost.CI
The existing steps build every example on Linux and macOS:
cargo clippy --workspace --all-targets -- -D warningsand
cargo test --workspace. The build without default features doesn't build examples; with them,schemasisskipped by its required features. No step is added. Coverage doesn't count the examples, which can't run there:
cargo-llvm-cov leaves
examples/out of its report, and a stub example left the totals where they were.Testing
Each example ran against
apachepulsar/pulsar:5.0.1standalone: the producer; the Queue consumer, which got thenegatively acknowledged message again with a redelivery count of 1; the Stream consumer; the Checkpoint consumer
twice, the second run reading only the four messages stored after the first; the local example's 20 messages from two
loops; blocking; schemas, with the generic record's fields; pipelining's 12,000 sends.
authenticationran against abroker with TLS and token and TLS authentication, with a token, a token file and a client certificate, and failed with
Authenticationwithout credentials.