MCPcopy Create free account
hub / github.com/cel-expr/cel-go / ContextEval

Method ContextEval

cel/program.go:424–439  ·  view source on GitHub ↗

ContextEval implements the Program interface.

(ctx context.Context, input any)

Source from the content-addressed store, hash-verified

422
423// ContextEval implements the Program interface.
424func (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.
442func (p *prog) newExecutionFrame(input any) (*interpreter.ExecutionFrame, error) {

Callers

nothing calls this directly

Calls 5

newExecutionFrameMethod · 0.95
EvalMethod · 0.95
CloseMethod · 0.80
SetContextMethod · 0.80
IsMethod · 0.45

Tested by

no test coverage detected