Electric.ShapeCache.ShapeStatusBehaviour behaviour (electric v1.2.4)

View Source

Behaviour defining the ShapeStatus functions to be used in mocks

Summary

Types

shape_handle()

@type shape_handle() :: Electric.ShapeCacheBehaviour.shape_handle()

stack_id()

@type stack_id() :: Electric.stack_id()

stack_ref()

@type stack_ref() :: atom() | stack_id() | [{:stack_id, stack_id()}]

xmin()

@type xmin() :: non_neg_integer()

Callbacks

add_shape(stack_ref, t)

@callback add_shape(stack_ref(), Electric.Shapes.Shape.t()) ::
  {:ok, shape_handle()} | {:error, term()}

consume_shape_storage_state(stack_ref, shape_handle)

@callback consume_shape_storage_state(stack_ref(), shape_handle()) :: term() | nil

count_shapes(stack_ref)

@callback count_shapes(stack_ref()) :: non_neg_integer()

fetch_shape_by_handle(stack_ref, shape_handle)

@callback fetch_shape_by_handle(stack_ref(), shape_handle()) ::
  {:ok, Electric.Shapes.Shape.t()} | :error

get_existing_shape(stack_ref, arg2)

@callback get_existing_shape(stack_ref(), Electric.Shapes.Shape.t() | shape_handle()) ::
  {shape_handle(), Electric.Replication.LogOffset.t()} | nil

initialise_shape(stack_ref, shape_handle, xmin, t)

@callback initialise_shape(
  stack_ref(),
  shape_handle(),
  xmin(),
  Electric.Replication.LogOffset.t()
) :: :ok

initialize_from_storage(stack_ref, storage)

@callback initialize_from_storage(stack_ref(), Electric.ShapeCache.Storage.storage()) ::
  :ok | {:error, term()}

list_shapes(stack_ref)

@callback list_shapes(stack_ref()) :: [{shape_handle(), Electric.Shapes.Shape.t()}]

mark_snapshot_started(stack_ref, shape_handle)

@callback mark_snapshot_started(stack_ref(), shape_handle()) :: :ok

remove_shape(stack_ref, shape_handle)

@callback remove_shape(stack_ref(), shape_handle()) ::
  {:ok, Electric.Shapes.Shape.t()} | {:error, term()}

reset(stack_ref)

@callback reset(stack_ref()) :: :ok

set_latest_offset(stack_ref, shape_handle, t)

@callback set_latest_offset(
  stack_ref(),
  shape_handle(),
  Electric.Replication.LogOffset.t()
) :: :ok

set_shape_storage_state(stack_ref, shape_handle, term)

@callback set_shape_storage_state(stack_ref(), shape_handle(), term()) :: :ok

set_snapshot_xmin(stack_ref, shape_handle, xmin)

@callback set_snapshot_xmin(stack_ref(), shape_handle(), xmin()) :: :ok

shape_last_used_table(stack_ref)

@callback shape_last_used_table(stack_ref()) :: atom()

shape_meta_table(stack_ref)

@callback shape_meta_table(stack_ref()) :: atom()

snapshot_started?(stack_ref, shape_handle)

@callback snapshot_started?(stack_ref(), shape_handle()) :: boolean()

terminate(stack_ref, t)

@callback terminate(stack_ref(), String.t()) :: :ok | {:error, term()}