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

Method ContextEval

cel/program.go:407–422  ·  view source on GitHub ↗

ContextEval implements the Program interface.

(ctx context.Context, input any)

Source from the content-addressed store, hash-verified

405
406// ContextEval implements the Program interface.
407func (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.
425func (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