456
// saveStartedResult transitions the operation to started in response to an async (pending) start
457
// response so it can later complete via callback.
458
>
func (e taskExecutor) saveStartedResult(env hsm.Environment, node *hsm.Node, operation Operation, result *nexusrpc.ClientStartOperationResponse[*commonpb.Payload]) error {
executors.go
459
>
eventID, err := hsm.EventIDFromToken(operation.ScheduledEventToken)
460
>
if err != nil {
461
return err
462
}
463
>
links := commonnexus.ConvertNexusLinksToProtoLinks(result.Links, e.Logger)
executors.go
464
>
event := node.AddHistoryEvent(enumspb.EVENT_TYPE_NEXUS_OPERATION_STARTED, func(e *historypb.HistoryEvent) {
465
>
// nolint:revive // We must mutate here even if the linter doesn't like it.
466
>
e.Attributes = &historypb.HistoryEvent_NexusOperationStartedEventAttributes{
467
>
NexusOperationStartedEventAttributes: &historypb.NexusOperationStartedEventAttributes{
468
>
ScheduledEventId: eventID,
469
>
OperationToken: result.Pending.Token,
470
>
// TODO(bergundy): Remove this fallback after the 1.27 release.
471
>
OperationId: result.Pending.Token,
472
>
RequestId: operation.RequestId,
473
>
},
474
>
}
475
>
// nolint:revive // We must mutate here even if the linter doesn't like it.
476
>
e.Links = links
477
>
})
478
>
return hsm.MachineTransition(node, func(operation Operation) (hsm.TransitionOutput, error) {
479
>
return TransitionStarted.Apply(operation, EventStarted{
480
>
Time: env.Now(),
481
>
Node: node,
482
>
Attributes: event.GetNexusOperationStartedEventAttributes(),
483
>
})
484
>
})
485
}
486