hecate_plugin_store (hecate_sdk v0.6.2)

View Source

ReckonDB store setup helper for plugins.

Creates and configures a plugin's event store based on its hecate_store_config record.

Plugins with multiple bounded contexts use start_extra_stores/2 to create additional stores beyond the primary one (which the plugin loader creates via store_config/0). Use start_subscriptions/1 to wire up evoq event delivery for all stores.

Summary

Functions

Create a ReckonDB store for a plugin. PluginName is used to derive the data directory. Config comes from the plugin's store_config/0 callback.

Dispatch an evoq command to a plugin's store. Convenience wrapper that sets the standard dispatch options.

Create additional ReckonDB stores for a plugin. The primary store is created by the plugin loader via store_config/0. Call this from init/1 for extra bounded contexts.

Start evoq store subscriptions for a list of store IDs. Subscriptions enable event delivery from ReckonDB to evoq projections and process managers. Call after stores are created.

Functions

create_store(PluginName, Hecate_store_config)

-spec create_store(PluginName :: string() | binary(),
                   Config ::
                       #hecate_store_config{store_id :: atom(),
                                            dir_name :: string(),
                                            description :: string(),
                                            options :: map()}) ->
                      ok | {error, term()}.

Create a ReckonDB store for a plugin. PluginName is used to derive the data directory. Config comes from the plugin's store_config/0 callback.

dispatch(StoreId, Command, ExtraOpts)

-spec dispatch(StoreId :: atom(), Command :: term(), ExtraOpts :: map()) -> ok | {error, term()}.

Dispatch an evoq command to a plugin's store. Convenience wrapper that sets the standard dispatch options.

start_extra_stores(BaseDataDir, StoreSpecs)

-spec start_extra_stores(BaseDataDir :: string(), StoreSpecs :: [{atom(), string(), string()}]) -> ok.

Create additional ReckonDB stores for a plugin. The primary store is created by the plugin loader via store_config/0. Call this from init/1 for extra bounded contexts.

StoreSpecs is a list of {StoreId, SubDir, Label} tuples: {orchestration_store, "orchestration", "Agent Orchestration"}

Each store gets a subdirectory under BaseDataDir.

start_subscriptions(StoreIds)

-spec start_subscriptions(StoreIds :: [atom()]) -> ok.

Start evoq store subscriptions for a list of store IDs. Subscriptions enable event delivery from ReckonDB to evoq projections and process managers. Call after stores are created.