(ctx context.Context, sessionID string, reason taskpkg.StopReason)
| 286 | } |
| 287 | |
| 288 | func (b *taskSessionBridge) RequestTaskStop(ctx context.Context, sessionID string, reason taskpkg.StopReason) error { |
| 289 | if ctx == nil { |
| 290 | return errors.New("daemon: request task stop context is required") |
| 291 | } |
| 292 | |
| 293 | trimmedID := strings.TrimSpace(sessionID) |
| 294 | if trimmedID == "" { |
| 295 | return fmt.Errorf("%w: task session stop id is required", taskpkg.ErrValidation) |
| 296 | } |
| 297 | |
| 298 | if requester, ok := b.sessions.(taskBridgeSessionRequestStopper); ok { |
| 299 | if err := requester.RequestStopWithCause( |
| 300 | ctx, |
| 301 | trimmedID, |
| 302 | taskStopCause(reason), |
| 303 | taskStopDetail(reason), |
| 304 | ); err != nil { |
| 305 | if errors.Is(err, session.ErrSessionNotFound) { |
| 306 | return nil |
| 307 | } |
| 308 | return err |
| 309 | } |
| 310 | return nil |
| 311 | } |
| 312 | |
| 313 | return b.ForceTaskStop(ctx, trimmedID, reason) |
| 314 | } |
| 315 | |
| 316 | func (b *taskSessionBridge) ForceTaskStop(ctx context.Context, sessionID string, reason taskpkg.StopReason) error { |
| 317 | if ctx == nil { |
nothing calls this directly
no test coverage detected