Annotai.Persistence.Adapter behaviour (Annotai v0.1.0)

Copy Markdown View Source

Behaviour for annotation persistence backends.

An adapter turns the in-memory annotation list into durable storage and back. The default is Annotai.Persistence.Adapter.File (an ETF snapshot of the whole set); the behaviour is the seam for alternative backends (e.g. a database) and for a fake adapter in tests.

config is the normalized persistence config (a map) — each adapter reads only the keys it cares about.

Summary

Types

Normalized persistence config; adapters pick the keys they need.

Callbacks

Load all persisted annotations. Absent storage returns {:ok, []}.

Persist annotations, replacing any previously stored set.

Types

config()

@type config() :: map()

Normalized persistence config; adapters pick the keys they need.

Callbacks

load(config)

@callback load(config()) :: {:ok, [Annotai.Annotation.t()]} | {:error, term()}

Load all persisted annotations. Absent storage returns {:ok, []}.

save(list, config)

@callback save([Annotai.Annotation.t()], config()) :: :ok | {:error, term()}

Persist annotations, replacing any previously stored set.