reckon_db_index_config (reckon_db v5.0.0)

View Source

Per-store secondary-index declaration registry.

A store declares which secondary indexes it maintains in #store_config.indexes (none by default). This module installs that declared list into persistent_term at store startup so the append hot path can read it without process-state coupling — exactly the pattern reckon_db_integrity_key uses for the HMAC key.

Storage

The declared index list is placed in persistent_term under {reckon_db, indexes, StoreId}. Callers read it via declared/1 on every append; the lookup is sub-microsecond.

Index kinds

  • tags — index every tag in #event.tags.
  • event_type — index #event.event_type.
  • {meta, Key} — index maps:get(Key, metadata) when present.

See plans/DESIGN_SECONDARY_INDEX.md.

Summary

Functions

Remove a store's index declaration from persistent_term (shutdown / test isolation).

The declared index list for a store ([] if none / not loaded).

Whether a given index kind is declared for a store. Kind is an index_decl() (tags, event_type, or {meta, Key}). Drives the read-path "use index vs scan-and-warn" decision.

Install a store's declared index list into persistent_term at startup. Idempotent: re-loading overwrites the previous declaration.

Types

index_decl/0

-type index_decl() :: tags | event_type | {meta, Key :: binary()}.

integrity_config/0

-type integrity_config() :: disabled | #{enabled := true, key_source := integrity_key_source()}.

integrity_key_source/0

-type integrity_key_source() :: {env_var, EnvName :: binary()} | {sealed_file, Path :: file:filename()}.

store_config/0

-type store_config() ::
          #store_config{store_id :: atom(),
                        data_dir :: string(),
                        mode :: single | cluster,
                        timeout :: pos_integer(),
                        writer_pool_size :: pos_integer(),
                        reader_pool_size :: pos_integer(),
                        gateway_pool_size :: pos_integer(),
                        options :: map(),
                        integrity :: integrity_config(),
                        indexes :: [index_decl()]}.

Functions

clear(StoreId)

-spec clear(StoreId :: atom()) -> ok.

Remove a store's index declaration from persistent_term (shutdown / test isolation).

declared(StoreId)

-spec declared(StoreId :: atom()) -> [index_decl()].

The declared index list for a store ([] if none / not loaded).

is_indexed(StoreId, Kind)

-spec is_indexed(StoreId :: atom(), Kind :: index_decl()) -> boolean().

Whether a given index kind is declared for a store. Kind is an index_decl() (tags, event_type, or {meta, Key}). Drives the read-path "use index vs scan-and-warn" decision.

load(Store_config)

-spec load(store_config()) -> ok.

Install a store's declared index list into persistent_term at startup. Idempotent: re-loading overwrites the previous declaration.