( ctx context.Context, req contract.MemoryExtractorRetryRequest, )
| 277 | } |
| 278 | |
| 279 | func (e *daemonMemoryExtractor) Retry( |
| 280 | ctx context.Context, |
| 281 | req contract.MemoryExtractorRetryRequest, |
| 282 | ) (contract.MemoryExtractorRetryResponse, error) { |
| 283 | if e == nil || e.proposalSink == nil { |
| 284 | return contract.MemoryExtractorRetryResponse{}, errors.New("daemon: memory extractor is not configured") |
| 285 | } |
| 286 | failures, err := e.loadFailures() |
| 287 | if err != nil { |
| 288 | return contract.MemoryExtractorRetryResponse{}, err |
| 289 | } |
| 290 | targetFailureID := strings.TrimSpace(req.FailureID) |
| 291 | targetSessionID := strings.TrimSpace(req.SessionID) |
| 292 | var response contract.MemoryExtractorRetryResponse |
| 293 | for _, failure := range failures { |
| 294 | if targetFailureID != "" && failure.Payload.ID != targetFailureID { |
| 295 | continue |
| 296 | } |
| 297 | if targetSessionID != "" && failure.Payload.SessionID != targetSessionID { |
| 298 | continue |
| 299 | } |
| 300 | if err := ctx.Err(); err != nil { |
| 301 | return response, fmt.Errorf("daemon: retry memory extractor failures: %w", err) |
| 302 | } |
| 303 | candidates, decodeErr := failure.Candidates() |
| 304 | if decodeErr != nil { |
| 305 | response.Failed++ |
| 306 | continue |
| 307 | } |
| 308 | if len(candidates) == 0 { |
| 309 | response.Failed++ |
| 310 | continue |
| 311 | } |
| 312 | var failed bool |
| 313 | for _, candidate := range candidates { |
| 314 | if _, proposeErr := e.proposalSink.ProposeCandidate(ctx, candidate); proposeErr != nil { |
| 315 | failed = true |
| 316 | break |
| 317 | } |
| 318 | } |
| 319 | if failed { |
| 320 | response.Failed++ |
| 321 | continue |
| 322 | } |
| 323 | if err := fileutil.AtomicRemoveFile(failure.Payload.Path); err != nil { |
| 324 | return response, fmt.Errorf("daemon: remove retried extractor failure: %w", err) |
| 325 | } |
| 326 | response.Retried++ |
| 327 | } |
| 328 | return response, nil |
| 329 | } |
| 330 | |
| 331 | func (e *daemonMemoryExtractor) Drain(ctx context.Context) (contract.MemoryExtractorDrainResponse, error) { |
| 332 | if e == nil || e.runtime == nil { |
nothing calls this directly
no test coverage detected