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

Method ContextEval

cel/program.go:356–371  ·  view source on GitHub ↗

ContextEval implements the Program interface.

(ctx context.Context, input any)

Source from the content-addressed store, hash-verified

354
355// ContextEval implements the Program interface.
356func (p *prog) ContextEval(ctx context.Context, input any) (ref.Val, *EvalDetails, error) {
357 if ctx == nil {
358 return nil, nil, fmt.Errorf("context can not be nil")
359 }
360 frame, err := p.newExecutionFrame(input)
361 if err != nil {
362 return nil, nil, err
363 }
364 defer frame.Close()
365 frame.SetContext(ctx, p.interruptCheckFrequency)
366 out, det, errEval := p.Eval(frame)
367 if errEval != nil && errors.Is(errEval, interpreter.InterruptError{}) {
368 return out, det, fmt.Errorf("%w: %w", errEval, context.Cause(ctx))
369 }
370 return out, det, errEval
371}
372
373// newExecutionFrame creates an ExecutionFrame for the given input without a timeout context.
374func (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