use dex_sdk::{
Channel, Context, Flow, HandlerError, HandlerResult, PersistenceSchema, RetryPolicy, Step,
StepDecision, StepList, StepOptions, Wait,
};
pub(crate) struct AnyCommandCombinationWorkflow {
first: Channel<i32>,
second: Channel<i32>,
third: Channel<i32>,
start: AnyCommandCombinationStep,
}
impl AnyCommandCombinationWorkflow {
pub(crate) fn new() -> Self {
Self {
first: Channel::new("test-signal-1"),
second: Channel::new("test-signal-2"),
third: Channel::new("test-signal-3"),
start: AnyCommandCombinationStep,
}
}
}
impl Flow for AnyCommandCombinationWorkflow {
type StartInput = i32;
fn steps(&self) -> StepList<'_, Self::StartInput> {
StepList::start(&self.start)
}
fn persistence(&self) -> PersistenceSchema {
PersistenceSchema::new()
.channel(&self.first)
.channel(&self.second)
.channel(&self.third)
}
}
struct AnyCommandCombinationStep;
impl Step for AnyCommandCombinationStep {
type Input = i32;
fn wait_for(&self, _context: &mut Context, _input: i32) -> HandlerResult<Wait> {
Err(HandlerError::new(
"UnknownConditionId",
"Found unknown condition ID in the combination list",
))
}
fn execute(&self, _context: &mut Context, input: i32) -> HandlerResult<StepDecision> {
Ok(StepDecision::graceful_complete(input))
}
fn options(&self) -> StepOptions<Self::Input> {
StepOptions::new().wait_for_retry(RetryPolicy::new().maximum_attempts(1))
}
}