ContextEval implements the Program interface.
(ctx context.Context, input any)
| 422 | |
| 423 | // ContextEval implements the Program interface. |
| 424 | func (p *prog) ContextEval(ctx context.Context, input any) (ref.Val, *EvalDetails, error) { |
| 425 | if ctx == nil { |
| 426 | return nil, nil, fmt.Errorf("context can not be nil") |
| 427 | } |
| 428 | frame, err := p.newExecutionFrame(input) |
| 429 | if err != nil { |
| 430 | return nil, nil, err |
| 431 | } |
| 432 | defer frame.Close() |
| 433 | frame.SetContext(ctx, p.interruptCheckFrequency) |
| 434 | out, det, errEval := p.Eval(frame) |
| 435 | if errEval != nil && errors.Is(errEval, interpreter.InterruptError{}) { |
| 436 | return out, det, fmt.Errorf("%w: %w", errEval, context.Cause(ctx)) |
| 437 | } |
| 438 | return out, det, errEval |
| 439 | } |
| 440 | |
| 441 | // newExecutionFrame creates an ExecutionFrame for the given input without a timeout context. |
| 442 | func (p *prog) newExecutionFrame(input any) (*interpreter.ExecutionFrame, error) { |
nothing calls this directly
no test coverage detected