Skip to main content

EffectHandler

Trait EffectHandler 

pub trait EffectHandler: Send + Sync {
    // Required methods
    fn handles(&self, effect: &Effect) -> bool;
    fn perform(&self, effect: &Effect) -> Result<EffectResult, SomaError>;
}
Expand description

Performs one kind of effect.

Handlers are tried in order; the first that claims an effect wins.

Lives here rather than beside the driver that runs them, so a crate can implement a handler without depending on the execution engine — soma-llm is one, and what it needs is a provider client, not a scheduler.

Required Methods§

fn handles(&self, effect: &Effect) -> bool

Will this handler take that effect?

fn perform(&self, effect: &Effect) -> Result<EffectResult, SomaError>

Perform it. Blocking.

A transport failure should come back as [EffectResult::Failed], not Err — the step decides whether to retry, fall back, or stop. Reserve Err for conditions the step cannot act on.

Implementors§