Skip to main content

RuntimePlugin

Trait RuntimePlugin 

Source
pub trait RuntimePlugin {
    // Required methods
    fn name(&self) -> &'static str;
    fn schema_registry(&self) -> SchemaRegistry;
    fn run_tx(
        &self,
        tx: &mut dyn RuntimeHostContext,
        command: &dyn RuntimeCommandEnvelope,
    ) -> Result<(), RuntimePluginError>;

    // Provided methods
    fn command_definitions(&self) -> &'static [&'static CommandDefinition] { ... }
    fn validate_biz_invariants(
        &self,
        _ctx: &dyn BizInvariantReadContext,
    ) -> Result<(), String> { ... }
    fn on_unload(&mut self) -> Result<(), RuntimePluginUnloadError> { ... }
}
Expand description

Domain runtime plugin contract.

Required Methods§

Source

fn name(&self) -> &'static str

Stable plugin name.

Source

fn schema_registry(&self) -> SchemaRegistry

Schema registry exposed by this plugin.

Source

fn run_tx( &self, tx: &mut dyn RuntimeHostContext, command: &dyn RuntimeCommandEnvelope, ) -> Result<(), RuntimePluginError>

Executes one command transaction.

Provided Methods§

Source

fn command_definitions(&self) -> &'static [&'static CommandDefinition]

Command definitions exposed by this plugin.

Source

fn validate_biz_invariants( &self, _ctx: &dyn BizInvariantReadContext, ) -> Result<(), String>

Validate domain-specific business invariants against committed state.

Called at two points:

  • after recovery replay, before declaring recovered state healthy
  • before publishing a new recovery boundary (snapshot publication)

Return Ok(()) if all invariants hold, or Err(message) to block the operation. The default implementation performs no checks.

Source

fn on_unload(&mut self) -> Result<(), RuntimePluginUnloadError>

Called before plugin unload so domain code can release resources.

Implementors§