Runbox.StateStore.Entity (runbox v7.0.1)
Module defines struct which acts as state store envelope for any stateful runtime component.
Link to this section Summary
Functions
Confirm that all messages with lower timestamps were processed.
Returns entity id
Creates new state store entity
Returns entity schedule
Returns entity state
Returns entity timestamp
Set entity state
at the specified point in time.
Link to this section Types
id()
state()
@type state() :: term()
@type t() :: %Runbox.StateStore.Entity{ id: id(), last_savepoint: Runbox.StateStore.ScheduleUtils.epoch_ms(), next_savepoint: Runbox.StateStore.ScheduleUtils.epoch_ms(), run_id: String.t(), schedule: Runbox.StateStore.ScheduleUtils.schedule(), state: state(), timestamp: Runbox.StateStore.ScheduleUtils.epoch_ms() }
Link to this section Functions
ack_processed_time(entity, timestamp, save_mfa)
@spec ack_processed_time( t(), Runbox.StateStore.ScheduleUtils.epoch_ms(), {module(), atom(), list()} ) :: {:ok, t()} | {:error, term()}
Confirm that all messages with lower timestamps were processed.
When the timestamp is higher than next savepoint the state is persisted into StateStore
with
StateStore.save/4
and next savepoint target is determined and stored in the entity.
The state is persisted only once per every savepoint.
id(entity)
Returns entity id
new(run_id, id, schedule, timestamp, state)
@spec new( String.t(), id(), Runbox.StateStore.ScheduleUtils.schedule(), Runbox.StateStore.ScheduleUtils.epoch_ms(), state() ) :: t()
Creates new state store entity
schedule(entity)
@spec schedule(t()) :: Runbox.StateStore.ScheduleUtils.schedule()
Returns entity schedule
state(entity)
Returns entity state
timestamp(entity)
@spec timestamp(t()) :: Runbox.StateStore.ScheduleUtils.epoch_ms()
Returns entity timestamp
update_state(entity, timestamp, state)
@spec update_state(t(), Runbox.StateStore.ScheduleUtils.epoch_ms(), state()) :: t()
Set entity state
at the specified point in time.