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

Function wrapAsyncOp

common/decls/decls.go:987–994  ·  view source on GitHub ↗

wrapAsyncOp adapts a blocking function into the channel-based AsyncOp used internally. The blocking function is invoked synchronously and its result delivered on a buffered channel. The interpreter always invokes an AsyncOp from a dedicated goroutine, so running the blocking call inline here keeps

(fn functions.BlockingAsyncOp)

Source from the content-addressed store, hash-verified

985// call inline here keeps the framework to a single goroutine per async call rather than spawning
986// an additional one to bridge blocking-to-channel.
987func wrapAsyncOp(fn functions.BlockingAsyncOp) functions.AsyncOp {
988 return func(ctx context.Context, args ...ref.Val) <-chan ref.Val {
989 ch := make(chan ref.Val, 1)
990 ch <- fn(ctx, args...)
991 close(ch)
992 return ch
993 }
994}
995
996// LateFunctionBinding indicates that the function has a binding which is not known at compile time.
997// This is useful for functions which have side-effects or are not deterministically computable.

Callers 2

SingletonAsyncBindingFunction · 0.85
AsyncBindingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected