Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions core/src/worker/workflow/machines/nexus_operation_state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ fsm! {
pub(super) enum NexusOperationCommand {
#[display("Start")]
Start { operation_id: String },
#[display("StartSync")]
StartSync,
#[display("CancelBeforeStart")]
CancelBeforeStart,
#[display("Complete")]
Expand Down Expand Up @@ -185,9 +187,7 @@ impl ScheduledEventRecorded {
ca: NexusOperationCompletedEventAttributes,
) -> NexusOperationMachineTransition<Completed> {
NexusOperationMachineTransition::commands([
NexusOperationCommand::Start {
operation_id: String::default(),
},
NexusOperationCommand::StartSync,
NexusOperationCommand::Complete(ca.result),
])
}
Expand All @@ -197,9 +197,7 @@ impl ScheduledEventRecorded {
fa: NexusOperationFailedEventAttributes,
) -> NexusOperationMachineTransition<Failed> {
NexusOperationMachineTransition::commands([
NexusOperationCommand::Start {
operation_id: String::default(),
},
NexusOperationCommand::StartSync,
NexusOperationCommand::Fail(fa.failure.unwrap_or_else(|| Failure {
message: "Nexus operation failed but failure field was not populated".to_owned(),
..Default::default()
Expand All @@ -212,9 +210,7 @@ impl ScheduledEventRecorded {
ca: NexusOperationCanceledEventAttributes,
) -> NexusOperationMachineTransition<Cancelled> {
NexusOperationMachineTransition::commands([
NexusOperationCommand::Start {
operation_id: String::default(),
},
NexusOperationCommand::StartSync,
NexusOperationCommand::Cancel(ca.failure.unwrap_or_else(|| Failure {
message:
"Nexus operation was cancelled but failure field was not populated".to_owned(),
Expand All @@ -228,9 +224,7 @@ impl ScheduledEventRecorded {
toa: NexusOperationTimedOutEventAttributes,
) -> NexusOperationMachineTransition<TimedOut> {
NexusOperationMachineTransition::commands([
NexusOperationCommand::Start {
operation_id: String::default(),
},
NexusOperationCommand::StartSync,
NexusOperationCommand::TimedOut(toa.failure.unwrap_or_else(|| Failure {
message: "Nexus operation timed out but failure field was not populated".to_owned(),
..Default::default()
Expand Down Expand Up @@ -412,6 +406,15 @@ impl WFMachinesAdapter for NexusOperationMachine {
_: Option<EventInfo>,
) -> Result<Vec<MachineResponse>, WFMachinesError> {
Ok(match my_command {
NexusOperationCommand::StartSync => {
vec![
ResolveNexusOperationStart {
seq: self.shared_state.lang_seq_num,
status: Some(resolve_nexus_operation_start::Status::StartedSync(true)),
}
.into(),
]
}
NexusOperationCommand::Start { operation_id } => {
vec![
ResolveNexusOperationStart {
Expand Down
1 change: 1 addition & 0 deletions tests/integ_tests/workflow_tests/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async fn nexus_basic(
})
.await
.unwrap();
assert_eq!(started.operation_id, None);
let res = started.result().await;
Ok(res.into())
}
Expand Down
Loading