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 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 xmin() :: Electric.ShapeCacheBehaviour.xmin()
Functions
@spec add_shape(t(), Electric.Shapes.Shape.t()) :: {:ok, shape_handle()} | {:error, term()}
@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()}
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
@spec list_shapes(t()) :: [{shape_handle(), Electric.Shapes.Shape.t()}]
@spec remove_shape(t(), Electric.Shapes.Shape.t()) :: {:ok, t()} | {:error, term()}