Skip to content

IStateMachine

interface

Namespace: Orleans.Journaling

Defines the replay, snapshot, and acknowledgement protocol for a journal-backed state machine.
public interface IStateMachine

Remarks

Implementations are owned by a single Orleans.Journaling.JournaledStateManager and are accessed from one logical thread at a time. They participate in the journaling lifecycle as follows:

  • User code mutates in-memory state synchronously (typically by invoking codec helpers that both apply the mutation locally and emit the corresponding command to the journal).
  • When the application requests a write, the journaled state manager calls IStateMachine (and occasionally IStateMachine) to materialize the pending changes, then flushes the journal to durable storage.
  • IStateMachine is invoked when the durable write has been acknowledged. Implementations that need to know when state has actually been persisted (for example, to release waiters or trigger downstream notifications) should hook into this callback rather than treating in-memory mutations as durable.
  • A failed journal operation permanently fences the manager and requests grain deactivation. A new manager initializes new state instances by calling IStateMachine and replaying durable entries.

Application code prepares fallible work in operation-local data and stages only mutations which are safe to commit. Staged mutations are shared by all interleaved callers using the same manager. Storage acknowledgement establishes durability; recovery takes place in a fresh manager and state instances.

Methods