PauseTask marks one task as paused for future scheduler and claim eligibility.
( ctx context.Context, id string, req PauseTaskRequest, actor ActorContext, )
| 80 | |
| 81 | // PauseTask marks one task as paused for future scheduler and claim eligibility. |
| 82 | func (m *Service) PauseTask( |
| 83 | ctx context.Context, |
| 84 | id string, |
| 85 | req PauseTaskRequest, |
| 86 | actor ActorContext, |
| 87 | ) (*Task, error) { |
| 88 | if err := m.requireForceRunAuthority(actor); err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | normalized, err := normalizePauseTaskRequest(req) |
| 92 | if err != nil { |
| 93 | return nil, err |
| 94 | } |
| 95 | pauseStore, err := m.requireTaskPauseStore() |
| 96 | if err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | taskID := strings.TrimSpace(id) |
| 100 | previous, err := m.store.GetTask(ctx, taskID) |
| 101 | if err != nil { |
| 102 | return nil, err |
| 103 | } |
| 104 | if isTerminalTaskStatus(previous.Status) { |
| 105 | return nil, terminalTaskPauseError(previous) |
| 106 | } |
| 107 | if err := m.requireForceRunRate(actor, previous.ID); err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | updated, err := pauseStore.PauseTask(ctx, PauseMutation{ |
| 111 | TaskID: previous.ID, |
| 112 | Actor: actorLabel(actor), |
| 113 | Reason: normalized.Reason, |
| 114 | PausedAt: m.now().UTC(), |
| 115 | }) |
| 116 | if err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | if err := m.recordTaskEvent(ctx, updated.ID, "", taskEventPaused, actor, taskPausePayload{ |
| 120 | Manual: true, |
| 121 | ActorKind: actor.Actor.Kind.Normalize(), |
| 122 | ActorID: actor.Actor.Ref, |
| 123 | PreviousPaused: previous.Paused, |
| 124 | Paused: updated.Paused, |
| 125 | Reason: normalized.Reason, |
| 126 | Metadata: cloneRawJSON(normalized.Metadata), |
| 127 | }); err != nil { |
| 128 | return nil, err |
| 129 | } |
| 130 | return &updated, nil |
| 131 | } |
| 132 | |
| 133 | // ResumeTask clears one task pause for future scheduler and claim eligibility. |
| 134 | func (m *Service) ResumeTask( |
nothing calls this directly
no test coverage detected