Jidoka.Session.Transitions (Jidoka v0.9.0)

Copy Markdown View Source

Pure durable session state transitions.

This module validates revisions, leases, claims, checkpoints, commits, and recovery. It does not call a store or another external service.

Summary

Functions

Records a durable snapshot under an active lease.

Claims a session with a worker lease for one request.

Claims a caller-managed session without a store lease.

Commits session state and releases its active lease.

Validates a direct session write against the current session.

Replaces an expired lease for crash recovery.

Returns true when a running session has recoverable expired work.

Extends an active session lease.

Claims a hibernated or waiting session for resume.

Functions

checkpoint(session, lease_id, snapshot, opts)

@spec checkpoint(Jidoka.Session.Data.t(), String.t(), Jidoka.Snapshot.t(), keyword()) ::
  {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Records a durable snapshot under an active lease.

claim(session, request, opts)

@spec claim(Jidoka.Session.Data.t(), Jidoka.Turn.Request.t(), keyword()) ::
  {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Claims a session with a worker lease for one request.

claim_without_lease(session, request)

@spec claim_without_lease(Jidoka.Session.Data.t(), Jidoka.Turn.Request.t()) ::
  {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Claims a caller-managed session without a store lease.

commit(current, lease_id, completed, opts)

@spec commit(Jidoka.Session.Data.t(), String.t(), Jidoka.Session.Data.t(), keyword()) ::
  {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Commits session state and releases its active lease.

put(current, incoming)

@spec put(Jidoka.Session.Data.t() | nil, Jidoka.Session.Data.t()) ::
  {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Validates a direct session write against the current session.

recover(session, opts)

@spec recover(
  Jidoka.Session.Data.t(),
  keyword()
) :: {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Replaces an expired lease for crash recovery.

recoverable?(session, now_ms)

@spec recoverable?(Jidoka.Session.Data.t(), non_neg_integer()) :: boolean()

Returns true when a running session has recoverable expired work.

renew(session, lease_id, opts)

@spec renew(Jidoka.Session.Data.t(), String.t(), keyword()) ::
  {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Extends an active session lease.

resume(session, opts)

@spec resume(
  Jidoka.Session.Data.t(),
  keyword()
) :: {:ok, Jidoka.Session.Data.t()} | {:error, term()}

Claims a hibernated or waiting session for resume.