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

Function AsyncBinding

common/decls/decls.go:958–969  ·  view source on GitHub ↗

AsyncBinding provides the implementation of an asynchronous overload. The provided function is called in its own goroutine with the provided context. The function should block until the result is available, and the framework manages goroutine and channel lifecycle. This follows the same pattern use

(fn functions.BlockingAsyncOp)

Source from the content-addressed store, hash-verified

956// This follows the same pattern used by gRPC-Go and other major Go frameworks where user
957// code is synchronous and the framework manages concurrency.
958func AsyncBinding(fn functions.BlockingAsyncOp) OverloadOpt {
959 return func(o *OverloadDecl) (*OverloadDecl, error) {
960 if o.HasBinding() {
961 return nil, fmt.Errorf("overload already has a binding: %s", o.ID())
962 }
963 if o.hasLateBinding {
964 return nil, fmt.Errorf("overload already has a late binding: %s", o.ID())
965 }
966 o.asyncOp = wrapAsyncOp(fn)
967 return o, nil
968 }
969}
970
971// wrapAsyncOp adapts a blocking function into the channel-based AsyncOp used internally.
972//

Callers 7

AsyncBindingFunction · 0.92
TimeoutBindingFunction · 0.92
RetryBindingFunction · 0.92
TestAsyncBindingFunction · 0.70

Calls 3

wrapAsyncOpFunction · 0.85
HasBindingMethod · 0.80
IDMethod · 0.65

Tested by 4

TestAsyncBindingFunction · 0.56