ContextEval implements the Program interface.
(ctx context.Context, input any)
| 354 | |
| 355 | // ContextEval implements the Program interface. |
| 356 | func (p *prog) ContextEval(ctx context.Context, input any) (ref.Val, *EvalDetails, error) { |
| 357 | if ctx == nil { |
| 358 | return nil, nil, fmt.Errorf("context can not be nil") |
| 359 | } |
| 360 | frame, err := p.newExecutionFrame(input) |
| 361 | if err != nil { |
| 362 | return nil, nil, err |
| 363 | } |
| 364 | defer frame.Close() |
| 365 | frame.SetContext(ctx, p.interruptCheckFrequency) |
| 366 | out, det, errEval := p.Eval(frame) |
| 367 | if errEval != nil && errors.Is(errEval, interpreter.InterruptError{}) { |
| 368 | return out, det, fmt.Errorf("%w: %w", errEval, context.Cause(ctx)) |
| 369 | } |
| 370 | return out, det, errEval |
| 371 | } |
| 372 | |
| 373 | // newExecutionFrame creates an ExecutionFrame for the given input without a timeout context. |
| 374 | func (p *prog) newExecutionFrame(input any) (*interpreter.ExecutionFrame, error) { |
nothing calls this directly
no test coverage detected