( ctx context.Context, approvalTask *Task, req ExecutionRequest, executionIdempotencyKey string, actor ActorContext, )
| 755 | } |
| 756 | |
| 757 | func (m *Service) approvalAutoEnqueueExecution( |
| 758 | ctx context.Context, |
| 759 | approvalTask *Task, |
| 760 | req ExecutionRequest, |
| 761 | executionIdempotencyKey string, |
| 762 | actor ActorContext, |
| 763 | ) (*Execution, bool, error) { |
| 764 | if approvalTask == nil || |
| 765 | !approvalTask.AutoEnqueueOnReady || |
| 766 | approvalTask.Status.Normalize() != TaskStatusReady { |
| 767 | return nil, false, nil |
| 768 | } |
| 769 | trigger := autoEnqueueTrigger{ |
| 770 | Kind: autoEnqueueTriggerApprovalGranted, |
| 771 | Ref: approvalTask.ID, |
| 772 | } |
| 773 | run, err := m.EnqueueRun(ctx, EnqueueRun{ |
| 774 | TaskID: approvalTask.ID, |
| 775 | IdempotencyKey: trigger.idempotencyKey(approvalTask.ID), |
| 776 | NetworkChannel: req.NetworkChannel, |
| 777 | Metadata: req.Metadata, |
| 778 | }, actor) |
| 779 | if err != nil { |
| 780 | return nil, false, err |
| 781 | } |
| 782 | if err := m.saveApprovalAutoEnqueueIdempotencyAlias( |
| 783 | ctx, |
| 784 | approvalTask.ID, |
| 785 | run.ID, |
| 786 | executionIdempotencyKey, |
| 787 | actor, |
| 788 | ); err != nil { |
| 789 | return nil, false, err |
| 790 | } |
| 791 | taskRecord, err := m.store.GetTask(ctx, run.TaskID) |
| 792 | if err != nil { |
| 793 | return nil, false, err |
| 794 | } |
| 795 | m.recordAutoEnqueueTriggered(ctx, *approvalTask, run, trigger, actor) |
| 796 | return &Execution{ |
| 797 | Task: taskRecord, |
| 798 | Run: *run, |
| 799 | Action: ExecutionActionApproval, |
| 800 | }, true, nil |
| 801 | } |
| 802 | |
| 803 | func (m *Service) saveApprovalAutoEnqueueIdempotencyAlias( |
| 804 | ctx context.Context, |
no test coverage detected