Skip to content

Commit 046fc24

Browse files
l46kokcopybara-github
authored andcommitted
Prepare for planner migration by shifting standard CEL builders to proxy the legacy runtime
PiperOrigin-RevId: 941221739
1 parent 8f05b8e commit 046fc24

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

bundle/src/main/java/dev/cel/bundle/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ java_library(
5454
"//parser",
5555
"//runtime",
5656
"//runtime:runtime_planner_impl",
57+
"@maven//:com_google_errorprone_error_prone_annotations",
5758
],
5859
)
5960

bundle/src/main/java/dev/cel/bundle/CelFactory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package dev.cel.bundle;
1616

17+
import com.google.errorprone.annotations.InlineMe;
1718
import dev.cel.checker.CelCheckerLegacyImpl;
1819
import dev.cel.common.CelOptions;
1920
import dev.cel.compiler.CelCompiler;
@@ -34,8 +35,20 @@ private CelFactory() {}
3435
*
3536
* <p>Note, the {@link CelOptions#current}, standard CEL function libraries, and linked message
3637
* evaluation are enabled by default.
38+
*
3739
*/
40+
@InlineMe(
41+
replacement = "CelFactory.legacyCelBuilder()",
42+
imports = "dev.cel.bundle.CelFactory")
3843
public static CelBuilder standardCelBuilder() {
44+
return legacyCelBuilder();
45+
}
46+
47+
/**
48+
* Creates a builder for configuring a legacy CEL using current parser for the parse, type-check,
49+
* and eval of expressions.
50+
*/
51+
public static CelBuilder legacyCelBuilder() {
3952
return CelImpl.newBuilder(
4053
CelCompilerImpl.newBuilder(
4154
CelParserImpl.newBuilder(), CelCheckerLegacyImpl.newBuilder()),

runtime/src/main/java/dev/cel/runtime/CelRuntimeFactory.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package dev.cel.runtime;
1616

17+
import com.google.errorprone.annotations.InlineMe;
1718
import dev.cel.common.CelOptions;
1819

1920
/** Helper class to construct new {@code CelRuntime} instances. */
@@ -24,8 +25,25 @@ public final class CelRuntimeFactory {
2425
*
2526
* <p>Note, the {@link CelOptions#current}, standard CEL function libraries, and linked message
2627
* evaluation are enabled by default.
28+
*
29+
* <p>Note: This standard runtime currently proxies the legacy runtime, which will be deprecated.
30+
* Callers are strongly encouraged to migrate to the planner ({@link #plannerRuntimeBuilder()}).
31+
*
2732
*/
33+
@InlineMe(
34+
replacement = "CelRuntimeFactory.legacyCelRuntimeBuilder()",
35+
imports = "dev.cel.runtime.CelRuntimeFactory")
2836
public static CelRuntimeBuilder standardCelRuntimeBuilder() {
37+
return legacyCelRuntimeBuilder();
38+
}
39+
40+
/**
41+
* Create a new builder for constructing a legacy {@code CelRuntime} instance.
42+
*
43+
* <p>Note: This legacy runtime will be deprecated. Callers are strongly encouraged to migrate to
44+
* the planner ({@link #plannerRuntimeBuilder()}).
45+
*/
46+
public static CelRuntimeBuilder legacyCelRuntimeBuilder() {
2947
return CelRuntimeLegacyImpl.newBuilder()
3048
.setOptions(CelOptions.current().build())
3149
// CEL-Internal-2

0 commit comments

Comments
 (0)