Add explicit publisher buffer leases - #118
Merged
Merged
Conversation
Reserve lease-aware channel capacity and expose safe multi-slot publishing across C++, C, Python, and Rust clients, including subscriber limits and shadow recovery.
Provide an RAII lease wrapper so unpublished slots are reliably released on early returns and document the preferred lifecycle.
Preserve queue delivery and recovery semantics across leased publish paths while retaining lease capacity accounting and cross-language coverage.
dallison
marked this pull request as ready for review
August 13, 2026 00:31
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.
Summary
Adds explicit publisher buffer leases so a publisher can own multiple unpublished channel slots at the same time. This supports asynchronous producers, external-memory pipelines, and workflows that must reclaim the exact slot reported by a retirement notification.
ScopedPublisherBufferLease, a move-only C++ RAII wrapper that automatically releases an unpublished lease on scope exit.lease_idtokens so stale leases cannot publish, release, or access metadata after a slot is reused.max_subscribers.How to use publisher leases
max_outstanding_slot_leaseson the publisher. The default is1.AcquireScopedBufferLease()(preferred) orAcquireBufferLease().int32_tslot ID from the retirement fd, and call the reclaim API. Reclamation returns a newlease_id.The existing
GetMessageBuffer()/PublishMessage()workflow remains available and unchanged. Applications should choose either the implicit-buffer or explicit-lease workflow for a publisher. Explicit leases do not hold the thread-safe client mutex for the lifetime of the buffer.For unreliable channels, registration enforces this capacity invariant:
This reserves enough headroom for every configured lease and active-message budget. Subscriber queue storage uses its separate queue arena and does not consume this slot budget.
Documentation
See Publisher Buffer Leases for complete C++, C, Python, and Rust examples, lease lifecycle rules, retirement and exact-slot reclamation, capacity accounting, and subscriber limits.
Test plan
bazelisk test //...bazelisk test //client:client_test --test_arg=--use_split_buffers