@@ -545,7 +545,7 @@ func (e taskExecutor) executeCancelationTask(ctx context.Context, env hsm.Enviro
545545 handlerError := nexus .HandlerErrorf (nexus .HandlerErrorTypeNotFound , "endpoint not registered" )
546546
547547 // The endpoint is not registered, immediately fail the invocation.
548- return e .saveCancelationResult (ctx , env , ref , handlerError )
548+ return e .saveCancelationResult (ctx , env , ref , handlerError , args . scheduledEventID )
549549 }
550550 return err
551551 }
@@ -612,7 +612,7 @@ func (e taskExecutor) executeCancelationTask(ctx context.Context, env hsm.Enviro
612612 e .Logger .Error ("Nexus CancelOperation request failed" , tag .Error (callErr ))
613613 }
614614
615- err = e .saveCancelationResult (ctx , env , ref , callErr )
615+ err = e .saveCancelationResult (ctx , env , ref , callErr , args . scheduledEventID )
616616
617617 if callErr != nil && isDestinationDown (callErr ) {
618618 err = queues .NewDestinationDownError (callErr .Error (), err )
@@ -625,6 +625,7 @@ type cancelArgs struct {
625625 service , operation , token , endpointID , endpointName , requestID string
626626 scheduledTime time.Time
627627 scheduleToCloseTimeout time.Duration
628+ scheduledEventID int64
628629}
629630
630631// loadArgsForCancelation loads state from the operation state machine that's the parent of the cancelation machine the
@@ -648,12 +649,16 @@ func (e taskExecutor) loadArgsForCancelation(ctx context.Context, env hsm.Enviro
648649 args .requestID = op .RequestId
649650 args .scheduledTime = op .ScheduledTime .AsTime ()
650651 args .scheduleToCloseTimeout = op .ScheduleToCloseTimeout .AsDuration ()
652+ args .scheduledEventID , err = hsm .EventIDFromToken (op .ScheduledEventToken )
653+ if err != nil {
654+ return err
655+ }
651656 return nil
652657 })
653658 return
654659}
655660
656- func (e taskExecutor ) saveCancelationResult (ctx context.Context , env hsm.Environment , ref hsm.Ref , callErr error ) error {
661+ func (e taskExecutor ) saveCancelationResult (ctx context.Context , env hsm.Environment , ref hsm.Ref , callErr error , scheduledEventID int64 ) error {
657662 return env .Access (ctx , ref , hsm .AccessWrite , func (n * hsm.Node ) error {
658663 return hsm .MachineTransition (n , func (c Cancelation ) (hsm.TransitionOutput , error ) {
659664 if callErr != nil {
@@ -667,6 +672,7 @@ func (e taskExecutor) saveCancelationResult(ctx context.Context, env hsm.Environ
667672 // nolint:revive // We must mutate here even if the linter doesn't like it.
668673 e .Attributes = & historypb.HistoryEvent_NexusOperationCancelRequestFailedEventAttributes {
669674 NexusOperationCancelRequestFailedEventAttributes : & historypb.NexusOperationCancelRequestFailedEventAttributes {
675+ ScheduledEventId : scheduledEventID ,
670676 RequestedEventId : c .RequestedEventId ,
671677 Failure : failure ,
672678 },
@@ -695,6 +701,7 @@ func (e taskExecutor) saveCancelationResult(ctx context.Context, env hsm.Environ
695701 // nolint:revive // We must mutate here even if the linter doesn't like it.
696702 e .Attributes = & historypb.HistoryEvent_NexusOperationCancelRequestCompletedEventAttributes {
697703 NexusOperationCancelRequestCompletedEventAttributes : & historypb.NexusOperationCancelRequestCompletedEventAttributes {
704+ ScheduledEventId : scheduledEventID ,
698705 RequestedEventId : c .RequestedEventId ,
699706 },
700707 }
0 commit comments