cel-go icon indicating copy to clipboard operation
cel-go copied to clipboard

Asynchronous function invocation support

Open TristonianJones opened this issue 5 years ago • 4 comments

The PR introduces support for asynchronous functions as CEL extensions.

The general algorithm for evaluation relies on the types.Unknown value to indicate when async calls relevant to the outcome of an expression. Async calls arguments are tracked, deduped, and memoized based on the overload id associated with the implementation.

It is possible to use partial state evaluation with async evaluation, though async calls will be resolved before any unknown attribute patterns. Using both features together may be inefficient; however, there is a general expectation that async function implementations may implement their own caching logic in order to handle repeated invocations of the same async function with the same arguments.

TristonianJones avatar Jun 19 '20 05:06 TristonianJones

While this PR does not specifically attempt to address https://github.com/google/cel-go/issues/356, it is possible to use the functions.AsyncOp implementation to solve this problem. The only caveat is that there is likely a 2x performance penalty for using the functions.AsyncOp purely for plumbing Activation data into a synchronous function.

TristonianJones avatar Jun 19 '20 17:06 TristonianJones

FYI @mswest46

TristonianJones avatar Jun 19 '20 17:06 TristonianJones