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

Method ContextEval

cel/program.go:539–557  ·  view source on GitHub ↗

ContextEval implements the Program interface.

(ctx context.Context, input any)

Source from the content-addressed store, hash-verified

537
538// ContextEval implements the Program interface.
539func (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.
560func (p *prog) newExecutionFrame(input any) (*interpreter.ExecutionFrame, error) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected