feat: consumer lease streaming & message delivery (story 1.7)#7
Merged
vieiralucas merged 5 commits intomainfrom Feb 12, 2026
Merged
feat: consumer lease streaming & message delivery (story 1.7)#7vieiralucas merged 5 commits intomainfrom
vieiralucas merged 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
2 issues found across 6 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="crates/fila-server/src/service.rs">
<violation number="1" location="crates/fila-server/src/service.rs:43">
P2: `weight` is hardcoded to `0` and `throttle_keys` to `vec![]` instead of carrying over the original message values. The `ReadyMessage` struct is missing these fields, so the data is silently lost during delivery. Consumers will see incorrect metadata. Consider adding `weight` and `throttle_keys` to `ReadyMessage` and populating them from the source `Message`.</violation>
</file>
<file name="crates/fila-core/src/broker/scheduler.rs">
<violation number="1" location="crates/fila-core/src/broker/scheduler.rs:227">
P1: Round-robin `consumer_idx` is a local variable reset to 0 on every `try_deliver_pending` call. Since each enqueue triggers a separate call, messages arriving one-at-a-time will always be offered to the same consumer first, completely defeating the intended round-robin distribution. Promote `consumer_idx` (or a per-queue equivalent) to a `Scheduler` field so the position persists across invocations.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
767fc0f to
bb6dc55
Compare
3f41912 to
c56d405
Compare
4970e1d to
8ad8619
Compare
75dd9e7 to
df92fa9
Compare
8ad8619 to
71e67d3
Compare
df92fa9 to
4222fdc
Compare
71e67d3 to
460bef4
Compare
4222fdc to
5841b6c
Compare
ab6e29a to
e6bfae9
Compare
6d915b3 to
b8e0d37
Compare
67ebcd2 to
e662cbf
Compare
b8e0d37 to
f66134b
Compare
e662cbf to
89e7d8e
Compare
0b01ecd to
03f341c
Compare
…1.7) add consumer registry to scheduler with per-consumer tokio mpsc channels. implement try_deliver_pending that scans for unleased messages, creates lease and lease_expiry entries atomically, and delivers to consumers in round-robin. implement Lease grpc rpc with two-channel bridge pattern (ReadyMessage -> LeaseResponse conversion via spawned task) and automatic consumer unregistration on stream close via tokio::select!.
03f341c to
942a6e7
Compare
vieiralucas
commented
Feb 11, 2026
- reorder lease-then-send to prevent delivering without a lease - roll back lease on try_send failure (channel full or closed) - log try_send failures with consumer id and message id - promote list_messages and lease write failures to error! level
c17df24 to
aa08438
Compare
- closed consumer channel: message delivered to next consumer - all consumers closed: lease rolled back, message preserved - full consumer channel: message overflows to next consumer - all consumers full: lease rolled back for undelivered message
vieiralucas
commented
Feb 12, 2026
87d7425 to
3d21a80
Compare
Member
Author
|
@cubic-dev-ai full review |
@vieiralucas I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
2 issues found across 6 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="crates/fila-core/src/broker/scheduler.rs">
<violation number="1" location="crates/fila-core/src/broker/scheduler.rs:28">
P2: Global `consumer_rr_idx` is shared across all queues, breaking per-queue round-robin fairness. Deliveries to queue A advance the index that queue B uses, causing uneven distribution. Additionally, `queue_consumers` is collected from a `HashMap` whose iteration order is non-deterministic — any consumer add/remove reshuffles the order, making the persisted index meaningless. Consider using a per-queue round-robin index (e.g., `HashMap<String, usize>`).</violation>
<violation number="2" location="crates/fila-core/src/broker/scheduler.rs:300">
P2: Silently ignoring lease rollback failures can orphan leases and block messages. If `write_batch` (delete) fails here, the lease persists and the message is stuck until natural lease expiry. At minimum, log an error so operators can detect this condition.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- replace global consumer_rr_idx with per-queue HashMap<String, usize> so deliveries to one queue don't affect another queue's distribution - log error on lease rollback failure instead of silently ignoring
This was referenced Feb 12, 2026
vieiralucas
added a commit
that referenced
this pull request
Mar 18, 2026
- apply_to_broker_storage now returns Result and propagates StorageError instead of silently swallowing storage failures (cubic #1) - add DeleteLeaseExpiry mutation in ack/nack replication paths to clean up orphaned lease expiry entries (cubic #3) - fix no-op leased_msg_keys.retain in recovery — now properly clears entries for the recovering queue before rebuild (cubic #4) - warn when create_group is called without broker_storage set (cubic #5) - check send_command result in watch_leader_changes — only update leading state on success so next poll retries on failure (cubic #6, #7) - trigger RecoverQueue on first-sight leader state to catch messages replicated between startup and first poll (cubic #8) - replace catch-all _ => {} with explicit variant listing in apply_to_broker_storage for compiler-enforced exhaustiveness
vieiralucas
added a commit
that referenced
this pull request
Mar 18, 2026
- apply_to_broker_storage now returns Result and propagates StorageError instead of silently swallowing storage failures (cubic #1) - add DeleteLeaseExpiry mutation in ack/nack replication paths to clean up orphaned lease expiry entries (cubic #3) - fix no-op leased_msg_keys.retain in recovery — now properly clears entries for the recovering queue before rebuild (cubic #4) - warn when create_group is called without broker_storage set (cubic #5) - check send_command result in watch_leader_changes — only update leading state on success so next poll retries on failure (cubic #6, #7) - trigger RecoverQueue on first-sight leader state to catch messages replicated between startup and first poll (cubic #8) - replace catch-all _ => {} with explicit variant listing in apply_to_broker_storage for compiler-enforced exhaustiveness
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
tokio::sync::mpscchannelstry_deliver_pending: scans for unleased messages, creates lease + lease_expiry entries atomically viawrite_batch, delivers to consumers in round-robinLeasegRPC RPC with two-channel bridge pattern (scheduler sendsReadyMessage, converter task maps toLeaseResponse)tokio::select!detecting both message arrival and client disconnectionTest plan
Summary by cubic
Implements a server‑streaming Lease RPC and a consumer registry to push messages instantly without polling. Adds per‑queue round‑robin delivery with lease‑first, atomic lease+expiry writes, per‑queue visibility timeouts (30s default), and auto cleanup on disconnect (Story 1.7).
New Features
Bug Fixes
Written for commit 6e63f64. Summary will update on new commits.