google / cel-go

Fast, portable, non-Turing complete expression evaluation with gradual typing (Go)
https://cel.dev
Apache License 2.0
2.19k stars 218 forks source link

AOT instead of JIT #979

Closed quantumsheep closed 2 months ago

quantumsheep commented 2 months ago

Feature request checklist

Change

Hey !

I want to cache the compiled CEL expression in database to bypass the compilation phase each time I need to execute the expression. For that I need the binary representation or whatever of the expression.

TristonianJones commented 2 months ago

Hi @quantumsheep, you would just use the output of the Compile step and store it as a protobuf if you need a binary rep. Then you'd convert it to a runtime ast.AST when you read it from the db and do all of the normal program plan steps.

Hopefully, that makes sense, but if not I'd recommend looking at the cel.AstToCheckedExpr method as a way of getting the binary rep you're looking for.