Skip to content

Commit ef56ab4

Browse files
committed
refactor: Simplify managedQueue to a decorator
Removes the complex, stateful signaling mechanism from the `managedQueue`. Its sole responsibility is now to decorate a `SafeQueue` with atomic, strictly consistent statistics tracking. This change is the foundational first step in moving the registry from a complex, event-driven lifecycle model to a simpler, lease-based one. The now-unused event and lifecycle types are also removed.
1 parent 66d8e28 commit ef56ab4

File tree

5 files changed

+79
-276
lines changed

5 files changed

+79
-276
lines changed

pkg/epp/flowcontrol/contracts/errors.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ var (
3333

3434
// ErrInvalidShardCount indicates that an invalid shard count was provided (e.g., zero or negative).
3535
ErrInvalidShardCount = errors.New("invalid shard count")
36+
37+
// ErrShardDraining indicates that an operation could not be completed because the target shard is in the process of
38+
// being gracefully drained. The caller should retry the operation on a different, Active shard.
39+
ErrShardDraining = errors.New("shard is draining")
3640
)

pkg/epp/flowcontrol/contracts/registry.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,16 @@ type RegistryShard interface {
163163
Stats() ShardStats
164164
}
165165

166-
// ManagedQueue defines the interface for a flow's queue instance on a specific shard.
167-
// It acts as a stateful decorator around an underlying `framework.SafeQueue`.
166+
// ManagedQueue defines the interface for a flow's queue on a specific shard.
167+
// It acts as a stateful decorator around an underlying `framework.SafeQueue`, augmenting it with statistics tracking.
168168
//
169169
// # Conformance
170170
//
171-
// - All methods MUST be goroutine-safe.
172-
// - All mutating methods (`Add()`, `Remove()`, etc.) MUST ensure that the underlying queue state and the statistics
173-
// (`Len`, `ByteSize`) are updated atomically relative to each other.
171+
// - Implementations MUST be goroutine-safe.
172+
// - All mutating methods MUST ensure that the underlying queue state and the public statistics (`Len`, `ByteSize`)
173+
// are updated as a single atomic transaction.
174+
// - The `Add` method MUST return an error wrapping `ErrShardDraining` if the queue instance belongs to a parent shard
175+
// that is no longer Active.
174176
type ManagedQueue interface {
175177
framework.SafeQueue
176178

pkg/epp/flowcontrol/registry/events.go

Lines changed: 0 additions & 127 deletions
This file was deleted.

pkg/epp/flowcontrol/registry/lifecycle.go

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)