pub struct SeqAllocator { /* private fields */ }Expand description
Leadership/epoch gate plus request validation for the dense path. Holds NO
per-key counter state — counters live in the durable layer and start is
assigned there. This type only decides “may this request proceed, and is it
well-formed?”.
Implementations§
Source§impl SeqAllocator
impl SeqAllocator
pub fn new() -> Self
Sourcepub fn become_leader(&mut self, epoch: Epoch)
pub fn become_leader(&mut self, epoch: Epoch)
Transition to leader state for epoch. The caller must already hold
consensus leadership for epoch before calling this.
pub fn step_down(&mut self)
pub fn is_leader(&self) -> bool
pub fn epoch(&self) -> Option<Epoch>
Sourcepub fn validate_request(
&self,
key: &str,
count: u32,
max_count: u32,
) -> Result<SeqKey, CoreError>
pub fn validate_request( &self, key: &str, count: u32, max_count: u32, ) -> Result<SeqKey, CoreError>
Validate a request without touching durable state. Leadership is checked
first; then count bounds (zero, then oversized), then key validity.
Returns the validated SeqKey.
max_count is the caller’s per-call ceiling — the server’s configured
ServerBuilder::max_seq_count, which defaults to
DEFAULT_MAX_SEQ_COUNT. Injecting it (rather than reading the constant
here) keeps the cap a server-side policy the operator can tune, while the
count >= 1 floor stays a hard invariant enforced unconditionally.