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

Method SetContext

interpreter/frame.go:87–101  ·  view source on GitHub ↗

SetContext sets the context for the execution frame.

(ctx context.Context, interruptCheckFrequency uint)

Source from the content-addressed store, hash-verified

85
86// SetContext sets the context for the execution frame.
87func (f *ExecutionFrame) SetContext(ctx context.Context, interruptCheckFrequency uint) error {
88 if f.parent != nil {
89 return errors.New("SetContext() called on child frame")
90 }
91 if f.ctx != nil {
92 return errors.New("SetContext() called more than once")
93 }
94 f.ctx = evalContextPool.Get().(*evalContext)
95 f.ctx.ctx, f.ctx.cancel = context.WithCancel(ctx)
96 f.ctx.interrupt = ctx.Done()
97 f.ctx.interruptCheckFrequency = interruptCheckFrequency
98 f.ctx.interruptCheckCount.Store(0)
99 f.ctx.interrupted.Store(false)
100 return nil
101}
102
103// Close releases the resources held by the execution frame and returns it to the pool.
104func (f *ExecutionFrame) Close() {

Callers 7

TestFrameCheckInterruptFunction · 0.80
TestFrameCloseFunction · 0.80
TestFrameSetContextFunction · 0.80
ContextEvalMethod · 0.80

Calls 2

NewMethod · 0.80
GetMethod · 0.65

Tested by 6

TestFrameCheckInterruptFunction · 0.64
TestFrameCloseFunction · 0.64
TestFrameSetContextFunction · 0.64