Skip to content

feat(primitive): add barrier and queue primitives#120

Merged
slow2342 merged 1 commit into
mainfrom
feat/primitive-barrier-queue
Jun 12, 2026
Merged

feat(primitive): add barrier and queue primitives#120
slow2342 merged 1 commit into
mainfrom
feat/primitive-barrier-queue

Conversation

@slow2342

Copy link
Copy Markdown
Owner

Summary

  • Add distributed barrier primitive with blocking semantics (create/release/query)
  • Add distributed FIFO queue primitive (enqueue/dequeue/peek)
  • Both primitives integrate with Raft state machine, lease system, and watch mechanism

Changes

  • proto/barrier.proto — Barrier gRPC service definition (Create, Release, Query)
  • proto/queue.proto — Queue gRPC service definition (Enqueue, Dequeue, Peek)
  • src/barrier/mod.rs — BarrierManager with 4-map index pattern, restore, lease integration
  • src/queue/mod.rs — QueueManager with sequential key generation, restore from meta prefix
  • src/api/barrier.rs — BarrierService with create_with_wait blocking semantics
  • src/api/queue.rs — QueueService implementing AetherQueue tonic trait
  • src/raft/mod.rs — Added RaftRequest/RaftResponse variants for barrier and queue
  • src/raft/state_machine.rs — Apply methods, dispatch arms, lease cleanup, watch events
  • src/main.rs — Manager instantiation and gRPC service registration
  • build.rs — Added barrier.proto and queue.proto to compilation
  • src/lib.rs, src/api/mod.rs — Module declarations and re-exports

Design

Barrier: Similar to lock — create holds a barrier that blocks other callers. Supports lease-based auto-release. Uses watch-based create_with_wait for blocking semantics (like election's campaign_with_wait).

Queue: Sequential keys (_aether_queue/<name>/<seq>) with meta key tracking next sequence. Dequeue scans prefix for front item and deletes atomically. Peek reads without removing.

Testing

  • All 146 unit tests pass
  • cargo clippy -- -D warnings passes
  • cargo fmt -- --check passes

Related issues

Refs #91

Add distributed barrier and FIFO queue primitives following the same
pattern as lock and election.

Barrier provides synchronization: create holds a barrier that blocks
other callers until released. Supports lease-based auto-release and
watch-based blocking semantics (create_with_wait).

Queue provides FIFO operations: enqueue adds items with sequential
keys, dequeue pops the front item atomically. Peek reads without
removing.

Both primitives emit watch events on state changes and integrate
with the Raft state machine, lease system, and gRPC API layer.
@slow2342
slow2342 merged commit 1e4c14a into main Jun 12, 2026
5 checks passed
@slow2342
slow2342 deleted the feat/primitive-barrier-queue branch June 12, 2026 13:14
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