google / cel-go

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

AOT instead of JIT #979

Closed quantumsheep closed 4 months ago

quantumsheep commented 4 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 4 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.