Skip to content

Commit 0c9e6f0

Browse files
authored
Populate ScheduledEventID on NexusOperationCancelRequestCompleted|Failed (temporalio#7612)
## What changed? Populating ScheduledEventID on NexusOperationCancelRequestCompleted and NexusOperationCancelRequestFailed events. Depends on API PR (see for more details): temporalio/api#572
1 parent 5fde766 commit 0c9e6f0

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

components/nexusoperations/executors.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ require (
5959
go.opentelemetry.io/otel/sdk v1.34.0
6060
go.opentelemetry.io/otel/sdk/metric v1.34.0
6161
go.opentelemetry.io/otel/trace v1.34.0
62-
go.temporal.io/api v1.47.1-0.20250416163440-8d5dc336831c
62+
go.temporal.io/api v1.47.1-0.20250416230922-71e208db57f4
6363
go.temporal.io/sdk v1.33.0
6464
go.temporal.io/version v0.3.0
6565
go.uber.org/automaxprocs v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC
385385
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
386386
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
387387
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
388-
go.temporal.io/api v1.47.1-0.20250416163440-8d5dc336831c h1:KCZNvVGBmJxMQ6OcMWx1TFx1qU8jx1X2OpH7521UwSA=
389-
go.temporal.io/api v1.47.1-0.20250416163440-8d5dc336831c/go.mod h1:iaxoP/9OXMJcQkETTECfwYq4cw/bj4nwov8b3ZLVnXM=
388+
go.temporal.io/api v1.47.1-0.20250416230922-71e208db57f4 h1:8f0MeKtxfAReDLFiqnf2HNPukUYwh51g5d9KZcizIAI=
389+
go.temporal.io/api v1.47.1-0.20250416230922-71e208db57f4/go.mod h1:iaxoP/9OXMJcQkETTECfwYq4cw/bj4nwov8b3ZLVnXM=
390390
go.temporal.io/sdk v1.33.0 h1:T91UzeRdlHTiMGgpygsItOH9+VSkg+M/mG85PqNjdog=
391391
go.temporal.io/sdk v1.33.0/go.mod h1:WwCmJZLy7zabz3ar5NRAQEygsdP8tgR9sDjISSHuWZw=
392392
go.temporal.io/version v0.3.0 h1:dMrei9l9NyHt8nG6EB8vAwDLLTwx2SvRyucCSumAiig=

0 commit comments

Comments
 (0)