evoq_read_model_ets (evoq v1.30.1)

View Source

ETS-based read model store implementation.

Default in-memory implementation of evoq_read_model behavior. Suitable for development, testing, and small-scale deployments.

Configuration

- name: ETS table name (default: auto-generated) - type: ETS table type (default: set) - access: public | protected | private (default: public)

Named tables are shared by default: if the table already exists, new instances join it instead of crashing. This allows multiple projections to write to the same read model while each maintaining their own checkpoint.

Not durable: the table belongs to the process that created it, so its rows go when that projection stops, and a projection on this read model refuses a checkpoint store (see evoq_read_model:durable/1).

Summary

Functions

Clear all data from the table.

Delete a key.

The rows live in an ETS table owned by the projection process.

Get a value by key.

Initialize ETS-backed read model.

List all key-value pairs with matching prefix. For ETS, prefix matching works on tuple/list keys.

Store a key-value pair.

Functions

clear(State)

-spec clear(#state{table :: ets:tid()}) -> {ok, #state{table :: ets:tid()}}.

Clear all data from the table.

delete(Key, State)

-spec delete(term(), #state{table :: ets:tid()}) -> {ok, #state{table :: ets:tid()}}.

Delete a key.

durable()

-spec durable() -> false.

The rows live in an ETS table owned by the projection process.

get(Key, State)

-spec get(term(), #state{table :: ets:tid()}) -> {ok, term()} | {error, not_found}.

Get a value by key.

init(Config)

-spec init(map()) -> {ok, #state{table :: ets:tid()}} | {error, term()}.

Initialize ETS-backed read model.

list(Prefix, State)

-spec list(term(), #state{table :: ets:tid()}) -> {ok, [{term(), term()}]}.

List all key-value pairs with matching prefix. For ETS, prefix matching works on tuple/list keys.

put(Key, Value, State)

-spec put(term(), term(), #state{table :: ets:tid()}) -> {ok, #state{table :: ets:tid()}}.

Store a key-value pair.