Skip to content

feat(consumer): scaffold KIP-932 share consumer surface#838

Draft
j7nw4r wants to merge 13 commits into
fede1024:masterfrom
j7nw4r:kip-932-share-consumer
Draft

feat(consumer): scaffold KIP-932 share consumer surface#838
j7nw4r wants to merge 13 commits into
fede1024:masterfrom
j7nw4r:kip-932-share-consumer

Conversation

@j7nw4r
Copy link
Copy Markdown
Contributor

@j7nw4r j7nw4r commented May 23, 2026

What this lands

Adds the public Rust surface for KIP-932 behind a new kip-932 cargo feature, off by default. Types compile and unit tests lock in the shape. Every runtime method returns a new KafkaError::Unsupported until librdkafka exposes the public share consumer C API; tracking at confluentinc/librdkafka#5441.

What KIP-932 changes

Kafka consumer groups normally assign each partition to one consumer at a time. Parallelism caps at the partition count, and a slow consumer blocks its partition. Share groups (this KIP) let multiple consumers cooperatively pull from the same partition. The broker hands out per-record locks with a timeout and tracks delivery counts. The consumer explicitly accepts each record (success), releases it (transient failure, broker redelivers), or rejects it (poison message, broker archives it).

Net effect: queue-style consumption on top of the existing log. At-least-once, no strict per-partition ordering, but you can scale consumers past the partition count without re-sharding.

Status

Draft, not ready to merge. The plan lives at PLAN.md (first commit) and will iterate in-tree as the upstream API settles. Once a public C surface lands, swapping the stubs for real FFI is mechanical.

Reviewer note

KafkaError gains a new Unsupported(&'static str) variant. It's #[non_exhaustive], so wildcard arms still work.

j7nw4r added 13 commits October 2, 2025 11:10
Mirrors the KIP's Java surface as a parallel Rust API gated behind a
new `kip-932` cargo feature, with stubbed FFI returning a new
`KafkaError::Unsupported` variant until librdkafka exposes the public
C API (tracking confluentinc/librdkafka#5441).
Clarifies the working mode: the plan ships in a draft PR on the fork
and evolves in-tree until librdkafka exposes the public KIP-932 C API.
Introduces the gated `consumer::share` module that will host the
KIP-932 share consumer surface. Submodules (`acknowledge`, `config`,
`consumer`, `context`, `records`) are declared but empty; subsequent
commits fill them in.

The `kip-932` cargo feature is off by default and added to the
docs.rs feature set so the surface renders on docs.rs once populated.
Introduces the value types that the share consumer surface will consume:

* `AcknowledgeType` (Accept, Release, Reject) with `Display` /
  `FromStr` round trip and case-insensitive parsing.
* `AcknowledgementMode`, `AutoOffsetReset`, `IsolationLevel` for the
  KIP-932 enum-valued configuration properties.
* `ShareConsumerConfig` builder layered on top of `ClientConfig`,
  emitting canonical librdkafka property keys
  (`share.acknowledgement.mode`, `group.share.delivery.attempt.limit`,
  etc.) via `into_client_config`.
* `AcknowledgementCommitResult` for surfacing async acknowledgement
  outcomes through the share consumer context.

Defaults follow KIP-932 (implicit acknowledgement, latest offset reset,
read_uncommitted isolation, 5 delivery attempts, 30s record lock).
Surfaces a non-retriable error for API methods that exist in
rust-rdkafka but are not yet backed by the underlying librdkafka build.
Used by the KIP-932 share consumer scaffolding until librdkafka exposes
the public share consumer C API.

`KafkaError` is already `#[non_exhaustive]`, so callers matching on it
already needed a fallback arm; no existing match becomes incomplete.
Introduces the central pieces of the KIP-932 surface:

* `ShareConsumerContext` mirrors `ConsumerContext` with a single
  `acknowledgement_commit` callback for async ack results.
* `ShareConsumer` trait spells out the runtime methods: subscribe /
  unsubscribe / subscription, poll, acknowledge / acknowledge_offset,
  commit_sync / commit_async, wakeup, close.
* `BaseShareConsumer` is the stub backing the trait. Construction
  parses `group.id` from `ClientConfig` (failure surfaces as the usual
  `ClientCreation` error). Every runtime method returns
  `KafkaError::Unsupported`; `wakeup` and `close` are intentionally
  safe no-ops so application shutdown paths still work.
* `ShareConsumerRecords` / `ShareRecord` are borrowed wrappers ready
  for librdkafka's eventual fetch surface; the stub never yields a
  non-empty batch.
* All new types are re-exported from `crate::consumer::share` and,
  under the `kip-932` feature, from `crate::consumer`.
Locks in the public shape so the eventual FFI swap is mechanical:

* `ShareConsumerConfig` emits the canonical librdkafka property keys
  (`share.acknowledgement.mode`, `group.share.*`, ...).
* `BaseShareConsumer` constructs via both `from_config` and
  `from_config_and_context`.
* Every runtime method returns `KafkaError::Unsupported` with a
  reason that names KIP-932.
* `close` and `wakeup` are safe no-ops so application shutdown paths
  remain valid.
* `AcknowledgeType` survives `to_string` / `FromStr` round-trips.

The test does not require a broker; the share consumer is a stub
until librdkafka exposes the public share consumer C API.
* `lint` runs clippy and the share-specific tests with
  `--features kip-932` so the gated surface is lint-clean and
  exercised on every PR.
* `check` matrix gains an Ubuntu entry that builds with the
  `kip-932` feature alone, so the feature flag is verified across
  the default toolchain.
* README and crate-level rustdoc list the new `kip-932` feature in
  the Features bullets, with the librdkafka tracking link.
* changelog.md gains an Unreleased entry covering both the share
  consumer scaffolding and the new `KafkaError::Unsupported` variant.
* Tighten the share module rustdoc so it builds clean under
  `-D rustdoc::redundant_explicit_links`.
clippy::needless_lifetimes on Rust 1.85+ flags impl<'a> ShareRecord<'a>
because the impl block doesn't use 'a beyond the type parameter. Switch
to impl ShareRecord<'_>. Caught by the upstream CI lint job (Rust 1.85).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant