Dsxir. RuntimeProgram. Store behaviour
(dsxir v0.2.0)
Copy Markdown
Behaviour for runtime-program persistence.
Two reference implementations ship in dsxir:
Dsxir.RuntimeProgram.Store.ETS- named ETS table owned by a supervisor-anchoredGenServer. Reads and writes bypass theGenServerand hit the table directly using:read_concurrency.Dsxir.RuntimeProgram.Store.File- a small file-backed reference impl that atomically writes one file per{id, version}under a configured directory.
Production users plug their own backend (Postgres, S3, etc.) by implementing the three callbacks.
Filter shape
list/2 accepts a keyword filter with at most two keys:
:tenant_id- matches againstmetadata.tenant_id; both string ("tenant_id") and atom (:tenant_id) keys are supported in the program's metadata map.:id- exact match against the program's:idfield.
No other filters are recognized in v1; extra keys are ignored.
Summary
Types
Callbacks
@callback get( t(), {id(), version()} ) :: {:ok, Dsxir.RuntimeProgram.t()} | {:error, :not_found}
@callback list(t(), filter()) :: {:ok, [Dsxir.RuntimeProgram.t()]}
@callback put(t(), Dsxir.RuntimeProgram.t()) :: :ok | {:error, term()}
Functions
@spec apply_filter([Dsxir.RuntimeProgram.t()], filter()) :: [Dsxir.RuntimeProgram.t()]
Filter a list of %RuntimeProgram{} structs by a filter/0 keyword.
Shared helper used by reference impls; production backends may push the filter into their query layer instead.