Skip to main content

process_manager

Attribute Macro process_manager 

Source
#[process_manager]
Expand description

Marks an impl block as a process manager with event handlers.

§Attributes

  • name = "pm-name" - The PM’s name (required)
  • domain = "pm-domain" - The PM’s own domain for state (required)
  • state = StateType - The PM’s state type (required)
  • inputs = ["domain1", "domain2"] - Input domains to subscribe to (required)

§Example

#[process_manager(name = "hand-flow", domain = "hand-flow", state = PMState, inputs = ["table", "hand"])]
impl HandFlowPM {
    #[applies(PMStateUpdated)]
    fn apply_state(state: &mut PMState, event: PMStateUpdated) {
        // ...
    }

    #[prepares(HandStarted)]
    fn prepare_hand(&self, trigger: &EventBook, state: &PMState, event: &HandStarted) -> Vec<Cover> {
        // ...
    }

    #[handles(HandStarted)]
    fn handle_hand(&self, trigger: &EventBook, state: &PMState, event: HandStarted, destinations: &[EventBook])
        -> CommandResult<ProcessManagerResponse> {
        // ...
    }
}