lightspeed/cluster/durable_session

Durable cluster-session contracts and ownership fencing for M27.

Types

Reconnect continuity measurements used for SLO checks.

pub type ContinuityReport {
  ContinuityReport(
    reconnect_latency_ms: Int,
    estimated_data_loss_events: Int,
    met: Bool,
  )
}

Constructors

  • ContinuityReport(
      reconnect_latency_ms: Int,
      estimated_data_loss_events: Int,
      met: Bool,
    )

Durable session state tracked by the failover certification harness.

pub type DurableSession {
  DurableSession(
    backend: PersistenceBackend,
    resume_policy: ResumePolicy,
    fence: OwnershipFence,
    snapshot: Snapshot,
    journal_rev: List(JournalEntry),
    continuity_slo_ms: Int,
    max_data_loss_events: Int,
  )
}

Constructors

Journal entries persisted for replay and diagnostics.

pub type JournalEntry {
  CounterDelta(delta: Int)
  CrashMarked(reason: String)
  Restarted(now_ms: Int)
  Reconnected(policy: ResumePolicy, route: String, now_ms: Int)
}

Constructors

  • CounterDelta(delta: Int)
  • CrashMarked(reason: String)
  • Restarted(now_ms: Int)
  • Reconnected(policy: ResumePolicy, route: String, now_ms: Int)

Durable lifecycle checkpoint labels.

pub type LifecycleState {
  Live
  Disconnected
  Crashed
}

Constructors

  • Live
  • Disconnected
  • Crashed

Ownership claim rejection reasons.

pub type OwnershipError {
  StaleOwner(current_epoch: Int, requested_epoch: Int)
  SplitBrain(
    current_owner: String,
    requested_owner: String,
    epoch: Int,
  )
  InvalidToken(owner: String, epoch: Int)
}

Constructors

  • StaleOwner(current_epoch: Int, requested_epoch: Int)
  • SplitBrain(
      current_owner: String,
      requested_owner: String,
      epoch: Int,
    )
  • InvalidToken(owner: String, epoch: Int)

Ownership fence used to reject stale owners.

pub type OwnershipFence {
  OwnershipFence(owner: String, epoch: Int, token: String)
}

Constructors

  • OwnershipFence(owner: String, epoch: Int, token: String)

Persistence profile used by one durable session.

pub type PersistenceBackend {
  SnapshotOnly(store: String, checkpoint_every: Int)
  JournalOnly(store: String)
  SnapshotJournal(
    snapshot_store: String,
    journal_store: String,
    checkpoint_every: Int,
  )
}

Constructors

  • SnapshotOnly(store: String, checkpoint_every: Int)
  • JournalOnly(store: String)
  • SnapshotJournal(
      snapshot_store: String,
      journal_store: String,
      checkpoint_every: Int,
    )

Reconnect policy for multi-node failover recovery.

pub type ResumePolicy {
  Resume
  Rehydrate
  Remount
}

Constructors

  • Resume
  • Rehydrate
  • Remount

Snapshot persisted for failover recovery.

pub type Snapshot {
  Snapshot(
    session_id: String,
    route: String,
    counter: Int,
    lifecycle: LifecycleState,
    checkpoint_epoch: Int,
    checkpoint_ms: Int,
  )
}

Constructors

  • Snapshot(
      session_id: String,
      route: String,
      counter: Int,
      lifecycle: LifecycleState,
      checkpoint_epoch: Int,
      checkpoint_ms: Int,
    )

Values

pub fn append_counter_delta(
  session: DurableSession,
  delta: Int,
  now_ms: Int,
) -> DurableSession

Append one counter-delta entry and update the snapshot.

pub fn backend(session: DurableSession) -> PersistenceBackend

Durable-state backend accessor.

pub fn backend_label(backend: PersistenceBackend) -> String

Backend label.

pub fn continuity_report(
  session: DurableSession,
  failover_at_ms: Int,
  reconnect_at_ms: Int,
) -> ContinuityReport

Deterministic continuity SLO report for one failover timeline.

pub fn continuity_signature(report: ContinuityReport) -> String

Continuity-report signature.

pub fn crash(
  session: DurableSession,
  reason: String,
) -> DurableSession

Mark a crash in snapshot + journal.

pub fn expected_token(
  session_id: String,
  owner: String,
  epoch: Int,
) -> String

Expected deterministic fence token.

pub fn fence(session: DurableSession) -> OwnershipFence

Durable-state fence accessor.

pub fn fence_signature(fence: OwnershipFence) -> String

Ownership-fence signature.

pub fn journal(session: DurableSession) -> List(JournalEntry)

Journal entries in append order.

pub fn journal_entry_label(entry: JournalEntry) -> String

Journal entry label.

pub fn lifecycle_label(lifecycle: LifecycleState) -> String

Lifecycle label.

pub fn ownership_error_label(error: OwnershipError) -> String

Ownership error label.

pub fn reconnect(
  session: DurableSession,
  policy: ResumePolicy,
  route: String,
  now_ms: Int,
) -> DurableSession

Reconnect using one recovery policy.

pub fn request_takeover(
  session: DurableSession,
  owner: String,
  epoch: Int,
  token: String,
  now_ms: Int,
) -> Result(DurableSession, OwnershipError)

Attempt ownership takeover under fencing rules.

pub fn restart(
  session: DurableSession,
  now_ms: Int,
) -> DurableSession

Mark a restart in snapshot + journal.

pub fn resume_policy_label(policy: ResumePolicy) -> String

Resume policy label.

pub fn signature(session: DurableSession) -> String

Deterministic durable-session signature.

pub fn snapshot(session: DurableSession) -> Snapshot

Durable-state snapshot accessor.

pub fn snapshot_signature(snapshot: Snapshot) -> String

Snapshot signature.

pub fn start(
  session_id: String,
  owner: String,
  route: String,
  backend: PersistenceBackend,
  resume_policy: ResumePolicy,
  now_ms: Int,
  continuity_slo_ms: Int,
  max_data_loss_events: Int,
) -> DurableSession

Start a durable session contract.

pub fn supported_backends() -> List(PersistenceBackend)

Supported backend matrix for M27 certification.

pub fn valid(session: DurableSession) -> Bool

Validate one durable-session contract.

Search Document