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

Function wrapAsyncOp

common/decls/decls.go:1072–1079  ·  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

1070// call inline here keeps the framework to a single goroutine per async call rather than spawning
1071// an additional one to bridge blocking-to-channel.
1072func wrapAsyncOp(fn functions.BlockingAsyncOp) functions.AsyncOp {
1073 return func(ctx context.Context, args ...ref.Val) <-chan ref.Val {
1074 ch := make(chan ref.Val, 1)
1075 ch <- fn(ctx, args...)
1076 close(ch)
1077 return ch
1078 }
1079}
1080
1081// LateFunctionBinding indicates that the function has a binding which is not known at compile time.
1082// 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