Skip to main content

CommandHandler

Trait CommandHandler 

Source
pub trait CommandHandler<C, R>: Send + Sync {
    // Required method
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 AppContext,
        cmd: C,
    ) -> Pin<Box<dyn Future<Output = Result<R, AppError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

命令处理器(Command Handler)

  • 处理具体类型的命令,执行业务用例并产生领域变化;
  • 建议仅做应用编排:参数校验、调用领域服务/仓储、发布事件等。

Required Methods§

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 AppContext, cmd: C, ) -> Pin<Box<dyn Future<Output = Result<R, AppError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

处理命令,返回是否执行成功

Implementors§