ContextEval implements the Program interface.
(ctx context.Context, input any)
| 405 | |
| 406 | // ContextEval implements the Program interface. |
| 407 | func (p *prog) ContextEval(ctx context.Context, input any) (ref.Val, *EvalDetails, error) { |
| 408 | if ctx == nil { |
| 409 | return nil, nil, fmt.Errorf("context can not be nil") |
| 410 | } |
| 411 | frame, err := p.newExecutionFrame(input) |
| 412 | if err != nil { |
| 413 | return nil, nil, err |
| 414 | } |
| 415 | defer frame.Close() |
| 416 | frame.SetContext(ctx, p.interruptCheckFrequency) |
| 417 | out, det, errEval := p.Eval(frame) |
| 418 | if errEval != nil && errors.Is(errEval, interpreter.InterruptError{}) { |
| 419 | return out, det, fmt.Errorf("%w: %w", errEval, context.Cause(ctx)) |
| 420 | } |
| 421 | return out, det, errEval |
| 422 | } |
| 423 | |
| 424 | // newExecutionFrame creates an ExecutionFrame for the given input without a timeout context. |
| 425 | func (p *prog) newExecutionFrame(input any) (*interpreter.ExecutionFrame, error) { |
nothing calls this directly
no test coverage detected