Search documentation of macula

# macula_mri_store behaviour (macula v4.4.1)

View Source

MRI 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

## Callbacks

delete/1
exists/1
export/0
import/1
list_by_realm/1
list_by_type/2
list_children/1
list_descendants/1
lookup/1
register/2
update/2

## Functions

adapter()

Get the configured storage adapter module.

delete(MRI)

Delete an MRI.

exists(MRI)

Check if an MRI exists.

export()

Export all MRIs (bulk operation).

import(Entries)

Import multiple MRIs (bulk operation).

list_by_realm(Realm)

List all MRIs in a realm.

list_by_type(Type, Realm)

List all MRIs of a given type in a realm.

list_children(MRI)

List direct children of an MRI.

list_descendants(MRI)

List all descendants of an MRI.

lookup(MRI)

Look up an MRI's metadata.

register(MRI, Metadata)

Register an MRI with metadata.

set_adapter(Module)

Set the storage adapter module.

update(MRI, Metadata)

Update an MRI's metadata.

# Callbacks

# delete/1

    -callback delete(MRI :: macula_mri:mri()) -> ok | {error, term()}.

# exists/1

    -callback exists(MRI :: macula_mri:mri()) -> boolean().

# export/0

(optional)

    -callback export() -> {ok, [{macula_mri:mri(), map()}]} | {error, term()}.

# import/1

(optional)

    -callback import(Entries :: [{macula_mri:mri(), map()}]) -> ok | {error, term()}.

# list_by_realm/1

    -callback list_by_realm(Realm :: macula_mri:realm()) -> [macula_mri:mri()].

# list_by_type/2

    -callback list_by_type(Type :: macula_mri:mri_type(), Realm :: macula_mri:realm()) -> [macula_mri:mri()].

# list_children/1

    -callback list_children(MRI :: macula_mri:mri()) -> [macula_mri:mri()].

# list_descendants/1

    -callback list_descendants(MRI :: macula_mri:mri()) -> [macula_mri:mri()].

# lookup/1

    -callback lookup(MRI :: macula_mri:mri()) -> {ok, Metadata :: map()} | {error, not_found | term()}.

# register/2

    -callback register(MRI :: macula_mri:mri(), Metadata :: map()) -> ok | {error, term()}.

# update/2

    -callback update(MRI :: macula_mri:mri(), Metadata :: map()) -> ok | {error, term()}.

# Functions

# adapter()

    -spec adapter() -> module().

Get the configured storage adapter module.

# delete(MRI)

    -spec delete(macula_mri:mri()) -> ok | {error, term()}.

Delete an MRI.

# exists(MRI)

    -spec exists(macula_mri:mri()) -> boolean().

Check if an MRI exists.

# export()

    -spec export() -> {ok, [{macula_mri:mri(), map()}]} | {error, term()}.

Export all MRIs (bulk operation).

# import(Entries)

    -spec import([{macula_mri:mri(), map()}]) -> ok | {error, term()}.

Import multiple MRIs (bulk operation).

# list_by_realm(Realm)

    -spec list_by_realm(macula_mri:realm()) -> [macula_mri:mri()].

List all MRIs in a realm.

# list_by_type(Type, 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.

# list_children(MRI)

    -spec list_children(macula_mri:mri()) -> [macula_mri:mri()].

List direct children of an MRI.

# list_descendants(MRI)

    -spec list_descendants(macula_mri:mri()) -> [macula_mri:mri()].

List all descendants of an MRI.

# lookup(MRI)

    -spec lookup(macula_mri:mri()) -> {ok, map()} | {error, not_found | term()}.

Look up an MRI's metadata.

# register(MRI, Metadata)

    -spec register(macula_mri:mri(), map()) -> ok | {error, term()}.

Register an MRI with metadata.

# set_adapter(Module)

    -spec set_adapter(module()) -> ok.

Set the storage adapter module.

# update(MRI, Metadata)

    -spec update(macula_mri:mri(), map()) -> ok | {error, term()}.

Update an MRI's metadata.