Electric.ShapeCache.ShapeStatus.ShapeDb (electric v1.4.13)

View Source

SQLite-backed persistent storage for shape metadata.

The WriteBuffer provides buffering for writes to prevent timeout cascades. Only handle_for_shape and shape_for_handle need buffer awareness since they are entry points for new requests. Other functions are called after ShapeStatus has already updated its ETS cache.

Summary

Types

shape_handle()

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

stack_id()

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

Functions

add_shape(stack_id, shape, shape_handle)

count_shapes(stack_id)

count_shapes!(stack_id)

explain(stack_id)

handle_for_shape(stack_id, shape)

Find a handle for a shape. Checks buffer first, then SQLite. Returns :error if the handle is tombstoned (being deleted).

handle_for_shape_critical(stack_id, shape)

Find a handle for a shape using the write connection to guarantee consistency.

list_shapes(stack_id)

list_shapes!(stack_id)

mark_snapshot_complete(stack_id, shape_handle)

pending_buffer_size(stack_id)

@spec pending_buffer_size(stack_id()) :: non_neg_integer()

Returns the number of pending writes in the buffer

reduce_shape_meta(stack_id, acc, reducer_fun)

reduce_shapes(stack_id, acc, reducer_fun)

remove_shape(stack_id, shape_handle)

reset(stack_id)

shape_for_handle(stack_id, shape_handle)

Find a shape by its handle. Checks buffer first, then SQLite. Returns :error if the handle is tombstoned (being deleted).

shape_handles_for_relations(stack_id, relations)

shape_handles_for_relations!(stack_id, relations)

statistics(stack_id)

validate_existing_shapes(stack_id)