View Source Electric.ShapeCache.ShapeStatus (electric v0.9.5)

Keeps track of shape state.

Can recover basic persisted shape metadata from shape storage to repopulate the in-memory cache.

The shape cache then loads this and starts processes (storage and consumer) for each {shape_handle, %Shape{}} pair. These then use their attached storage to recover the status information for the shape (snapshot xmin and latest offset).

The ETS metadata table name is part of the config because we need to be able to access the data in the ETS from anywhere, so there's an internal api, using the full state and an external api using just the table name.

Summary

Types

@type option() ::
  {:shape_meta_table, atom() | reference()}
  | {:storage, {module(), [term()]}}
  | {:root, binary()}
@type options() :: [option()]
@type shape_handle() :: Electric.ShapeCacheBehaviour.shape_handle()
@type t() :: %Electric.ShapeCache.ShapeStatus{
  root: String.t(),
  shape_meta_table: table(),
  storage: Electric.ShapeCache.Storage.storage()
}
@type table() :: atom() | reference()

Functions

@spec add_shape(t(), Electric.Shapes.Shape.t()) ::
  {:ok, shape_handle()} | {:error, term()}
Link to this function

get_existing_shape(meta_table, shape_or_id)

View Source
@spec get_existing_shape(t(), shape_handle() | Electric.Shapes.Shape.t()) ::
  nil | {shape_handle(), Electric.Replication.LogOffset.t()}
@spec get_existing_shape(table(), Electric.Shapes.Shape.t()) ::
  nil | {shape_handle(), Electric.Replication.LogOffset.t()}
@spec get_existing_shape(table(), shape_handle()) ::
  nil | {shape_handle(), Electric.Replication.LogOffset.t()}
@spec initialise(options()) :: {:ok, t()} | {:error, term()}
Link to this function

initialise_shape(state, shape_handle, snapshot_xmin, latest_offset)

View Source
@spec initialise_shape(
  t(),
  shape_handle(),
  xmin(),
  Electric.Replication.LogOffset.t()
) :: :ok
Link to this function

latest_offset(state, shape_handle)

View Source
Link to this function

latest_offset!(state, shape_handle)

View Source
@spec list_shapes(t()) :: [{shape_handle(), Electric.Shapes.Shape.t()}]
Link to this function

mark_snapshot_started(state, shape_handle)

View Source
Link to this function

remove_shape(state, shape_handle)

View Source
@spec remove_shape(t(), Electric.Shapes.Shape.t()) :: {:ok, t()} | {:error, term()}
Link to this function

set_latest_offset(state, shape_handle, latest_offset)

View Source
Link to this function

set_snapshot_xmin(state, shape_handle, snapshot_xmin)

View Source
Link to this function

snapshot_started?(state, shape_handle)

View Source
Link to this function

snapshot_xmin(state, shape_handle)

View Source