426
// Cancelation machine to the SCHEDULED state. Otherwise, the Cancelation machine will wait the
427
// Operation machine transition to the STARTED state.
428
>
func (o Operation) Cancel(node *hsm.Node, t time.Time, requestedEventID int64) (hsm.TransitionOutput, error) {
statemachine.go
429
>
child, err := node.AddChild(CancelationMachineKey, Cancelation{
430
>
NexusOperationCancellationInfo: &persistencespb.NexusOperationCancellationInfo{
431
>
RequestedEventId: requestedEventID,
432
>
},
433
>
})
434
>
if err != nil {
435
// This function should be called as part of command/event handling and it should not be called
436
// more than once.
437
return hsm.TransitionOutput{}, err
438
}
439
>
if o.State() != enumsspb.NEXUS_OPERATION_STATE_STARTED {
statemachine.go
440
// Operation hasn't started yet or has already completed. Either way, cannot schedule
441
// cancelation.