ContextEval implements the Program interface.
(ctx context.Context, input any)
| 537 | |
| 538 | // ContextEval implements the Program interface. |
| 539 | func (p *prog) ContextEval(ctx context.Context, input any) (ref.Val, *EvalDetails, error) { |
| 540 | if p == nil { |
| 541 | return nil, nil, errors.New("program is nil") |
| 542 | } |
| 543 | if ctx == nil { |
| 544 | return nil, nil, errors.New("context can not be nil") |
| 545 | } |
| 546 | frame, err := p.newExecutionFrame(input) |
| 547 | if err != nil { |
| 548 | return nil, nil, err |
| 549 | } |
| 550 | defer frame.Close() |
| 551 | frame.SetContext(ctx, p.interruptCheckFrequency) |
| 552 | out, det, errEval := p.Eval(frame) |
| 553 | if errEval != nil && errors.Is(errEval, interpreter.InterruptError{}) { |
| 554 | return out, det, fmt.Errorf("%w: %w", errEval, context.Cause(ctx)) |
| 555 | } |
| 556 | return out, det, errEval |
| 557 | } |
| 558 | |
| 559 | // newExecutionFrame creates an ExecutionFrame for the given input without a timeout context. |
| 560 | func (p *prog) newExecutionFrame(input any) (*interpreter.ExecutionFrame, error) { |
nothing calls this directly
no test coverage detected