371
env hsm.Environment,
372
ref hsm.Ref,
374
>
var eventToken []byte
375
>
err = env.Access(ctx, ref, hsm.AccessRead, func(node *hsm.Node) error {
376
>
operation, err := hsm.MachineData[Operation](node)
377
>
if err != nil {
378
return err
379
}
380
382
>
args.endpointID = operation.EndpointId
383
>
args.service = operation.Service
384
>
args.operation = operation.Operation
385
>
args.requestID = operation.RequestId
386
>
args.scheduledTime = operation.ScheduledTime.AsTime()
387
>
args.scheduleToCloseTimeout = operation.ScheduleToCloseTimeout.AsDuration()
388
>
args.scheduleToStartTimeout = operation.ScheduleToStartTimeout.AsDuration()
389
>
args.startToCloseTimeout = operation.StartToCloseTimeout.AsDuration()
390
>
eventToken = operation.ScheduledEventToken
391
>
event, err := node.LoadHistoryEvent(ctx, eventToken)
392
>
if err != nil {
393
return err
394
}
395
>
attrs := event.GetNexusOperationScheduledEventAttributes()
executors.go
396
>
args.payload = attrs.GetInput()
397
>
args.header = maps.Clone(attrs.GetNexusHeader())
398
>
args.nexusLink = commonnexus.ConvertLinkWorkflowEventToNexusLink(&commonpb.Link_WorkflowEvent{
399
>
Namespace: ns.Name().String(),
400
>
WorkflowId: ref.WorkflowKey.WorkflowID,
401
>
RunId: ref.WorkflowKey.RunID,
402
>
Reference: &commonpb.Link_WorkflowEvent_EventRef{
403
>
EventRef: &commonpb.Link_WorkflowEvent_EventReference{
404
>
EventId: event.GetEventId(),
405
>
EventType: event.GetEventType(),
406
>
},
407
>
},
408
>
})
409
>
args.namespaceFailoverVersion = event.Version
410
>
return nil
411
})
413
}
414
415
>
func (e taskExecutor) saveResult(ctx context.Context, env hsm.Environment, ref hsm.Ref, result *nexusrpc.ClientStartOperationResponse[*commonpb.Payload], callErr error) error {
executors.go
416
>
// emitMetrics is derived from the operation's resulting state inside the Access closure and
417
>
// invoked only after the write transaction commits successfully, so a failed commit (which
418
>
// retries the task) does not double-count the metric. See operationMetricsHandler's doc comment.
419
>
var emitMetrics func()
420
>
err := env.Access(ctx, ref, hsm.AccessWrite, func(node *hsm.Node) error {
421
>
operation, err := hsm.MachineData[Operation](node)
422
>
if err != nil {
423
return err
424
}
426
case callErr != nil:
427
err = e.handleStartOperationError(env, node, operation, callErr)