macula_mri_store behaviour (macula v0.20.5)
View SourceMRI Storage Behaviour
Defines the interface for MRI storage adapters. Implementations must provide registration, lookup, and hierarchy queries.
Example adapters: - macula_mri_khepri (distributed Raft-consensus via Khepri) - macula_mri_ets (in-memory, for development/testing)
Summary
Functions
Get the configured storage adapter module.
Delete an MRI.
Check if an MRI exists.
Export all MRIs (bulk operation).
Import multiple MRIs (bulk operation).
List all MRIs in a realm.
List all MRIs of a given type in a realm.
List direct children of an MRI.
List all descendants of an MRI.
Look up an MRI's metadata.
Register an MRI with metadata.
Set the storage adapter module.
Update an MRI's metadata.
Callbacks
-callback delete(MRI :: macula_mri:mri()) -> ok | {error, term()}.
-callback exists(MRI :: macula_mri:mri()) -> boolean().
-callback export() -> {ok, [{macula_mri:mri(), map()}]} | {error, term()}.
-callback import(Entries :: [{macula_mri:mri(), map()}]) -> ok | {error, term()}.
-callback list_by_realm(Realm :: macula_mri:realm()) -> [macula_mri:mri()].
-callback list_by_type(Type :: macula_mri:mri_type(), Realm :: macula_mri:realm()) -> [macula_mri:mri()].
-callback list_children(MRI :: macula_mri:mri()) -> [macula_mri:mri()].
-callback list_descendants(MRI :: macula_mri:mri()) -> [macula_mri:mri()].
-callback lookup(MRI :: macula_mri:mri()) -> {ok, Metadata :: map()} | {error, not_found | term()}.
-callback register(MRI :: macula_mri:mri(), Metadata :: map()) -> ok | {error, term()}.
-callback update(MRI :: macula_mri:mri(), Metadata :: map()) -> ok | {error, term()}.
Functions
-spec adapter() -> module().
Get the configured storage adapter module.
-spec delete(macula_mri:mri()) -> ok | {error, term()}.
Delete an MRI.
-spec exists(macula_mri:mri()) -> boolean().
Check if an MRI exists.
-spec export() -> {ok, [{macula_mri:mri(), map()}]} | {error, term()}.
Export all MRIs (bulk operation).
-spec import([{macula_mri:mri(), map()}]) -> ok | {error, term()}.
Import multiple MRIs (bulk operation).
-spec list_by_realm(macula_mri:realm()) -> [macula_mri:mri()].
List all MRIs in a realm.
-spec list_by_type(macula_mri:mri_type(), macula_mri:realm()) -> [macula_mri:mri()].
List all MRIs of a given type in a realm.
-spec list_children(macula_mri:mri()) -> [macula_mri:mri()].
List direct children of an MRI.
-spec list_descendants(macula_mri:mri()) -> [macula_mri:mri()].
List all descendants of an MRI.
-spec lookup(macula_mri:mri()) -> {ok, map()} | {error, not_found | term()}.
Look up an MRI's metadata.
-spec register(macula_mri:mri(), map()) -> ok | {error, term()}.
Register an MRI with metadata.
-spec set_adapter(module()) -> ok.
Set the storage adapter module.
-spec update(macula_mri:mri(), map()) -> ok | {error, term()}.
Update an MRI's metadata.