View Source Electric.ShapeCache.ShapeStatus (electric v0.7.0)
Keeps track of shape state.
Serializes just enough to some persistent storage to bootstrap the
ShapeCache by writing the mapping of shape_id => %Shape{}
to
storage.
The shape cache then loads this and starts processes (storage and consumer)
for each {shape_id, %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 options() :: [option()]
@type shape_id() :: Electric.ShapeCacheBehaviour.shape_id()
@type t() :: %Electric.ShapeCache.ShapeStatus{ persistent_kv: Electric.PersistentKV.t(), root: String.t(), shape_meta_table: table() }
@type xmin() :: Electric.ShapeCacheBehaviour.xmin()
Functions
@spec add_shape(t(), Electric.Shapes.Shape.t()) :: {:ok, shape_id(), Electric.Replication.LogOffset.t()} | {:error, term()}
@spec get_existing_shape(t(), shape_id() | Electric.Shapes.Shape.t()) :: nil | {shape_id(), Electric.Replication.LogOffset.t()}
@spec get_existing_shape(table(), Electric.Shapes.Shape.t()) :: nil | {shape_id(), Electric.Replication.LogOffset.t()}
@spec get_existing_shape(table(), shape_id()) :: nil | {shape_id(), Electric.Replication.LogOffset.t()}
@spec initialise_shape(t(), shape_id(), xmin(), Electric.Replication.LogOffset.t()) :: :ok
@spec list_shapes(t()) :: [{shape_id(), Electric.Shapes.Shape.t()}]