15
15
package dev .cel .runtime .async ;
16
16
17
17
import com .google .common .base .Preconditions ;
18
- import com .google .common .collect .ImmutableMap ;
19
- import com .google .common .collect .ImmutableSet ;
18
+ import com .google .common .collect .ImmutableList ;
20
19
import com .google .common .util .concurrent .ListeningExecutorService ;
21
20
import com .google .common .util .concurrent .MoreExecutors ;
22
21
import javax .annotation .concurrent .ThreadSafe ;
23
22
import dev .cel .common .CelAbstractSyntaxTree ;
24
- import dev .cel .runtime .CelAttributePattern ;
25
23
import dev .cel .runtime .CelEvaluationException ;
26
24
import dev .cel .runtime .CelRuntime ;
27
25
import dev .cel .runtime .CelRuntimeFactory ;
32
30
/** Default {@link CelAsyncRuntime} runtime implementation. See {@link AsyncProgramImpl}. */
33
31
@ ThreadSafe
34
32
final class CelAsyncRuntimeImpl implements CelAsyncRuntime {
35
- private final ImmutableMap <CelAttributePattern , CelUnknownAttributeValueResolver >
36
- unknownAttributeResolvers ;
37
- private final ImmutableSet <CelAttributePattern > unknownAttributePatterns ;
38
33
private final CelRuntime runtime ;
39
34
private final ListeningExecutorService executorService ;
40
35
private final ThreadSafeCelVariableResolver variableResolver ;
41
36
private final int maxEvaluateIterations ;
42
37
43
38
private CelAsyncRuntimeImpl (
44
- ImmutableMap <CelAttributePattern , CelUnknownAttributeValueResolver > unknownAttributeResolvers ,
45
- ImmutableSet <CelAttributePattern > unknownAttributePatterns ,
46
39
ThreadSafeCelVariableResolver variableResolver ,
47
40
CelRuntime runtime ,
48
41
ListeningExecutorService executorService ,
49
42
int maxEvaluateIterations ) {
50
- this .unknownAttributeResolvers = unknownAttributeResolvers ;
51
- this .unknownAttributePatterns = unknownAttributePatterns ;
52
43
this .variableResolver = variableResolver ;
53
44
this .runtime = runtime ;
54
45
this .executorService = executorService ;
55
46
this .maxEvaluateIterations = maxEvaluateIterations ;
56
47
}
57
48
58
49
private UnknownContext newAsyncContext () {
59
- return UnknownContext .create (variableResolver , unknownAttributePatterns );
50
+ return UnknownContext .create (variableResolver , ImmutableList . of () );
60
51
}
61
52
62
53
@ Override
63
54
public AsyncProgram createProgram (CelAbstractSyntaxTree ast ) throws CelEvaluationException {
64
55
return new AsyncProgramImpl (
65
56
runtime .createProgram (ast ),
66
57
executorService ,
67
- unknownAttributeResolvers ,
68
58
maxEvaluateIterations ,
69
59
newAsyncContext ());
70
60
}
@@ -76,17 +66,12 @@ static Builder newBuilder() {
76
66
/** {@link CelAsyncRuntimeBuilder} implementation for {@link CelAsyncRuntimeImpl}. */
77
67
private static final class Builder implements CelAsyncRuntimeBuilder {
78
68
private CelRuntime runtime ;
79
- private final ImmutableSet .Builder <CelAttributePattern > unknownAttributePatterns ;
80
- private final ImmutableMap .Builder <CelAttributePattern , CelUnknownAttributeValueResolver >
81
- unknownAttributeResolvers ;
82
69
private ListeningExecutorService executorService ;
83
70
private Optional <ThreadSafeCelVariableResolver > variableResolver ;
84
71
private int maxEvaluateIterations ;
85
72
86
73
private Builder () {
87
74
runtime = CelRuntimeFactory .standardCelRuntimeBuilder ().build ();
88
- unknownAttributeResolvers = ImmutableMap .builder ();
89
- unknownAttributePatterns = ImmutableSet .builder ();
90
75
variableResolver = Optional .empty ();
91
76
maxEvaluateIterations = DEFAULT_MAX_EVALUATE_ITERATIONS ;
92
77
}
@@ -97,20 +82,6 @@ public Builder setRuntime(CelRuntime runtime) {
97
82
return this ;
98
83
}
99
84
100
- @ Override
101
- public Builder addUnknownAttributePatterns (CelAttributePattern ... attributes ) {
102
- unknownAttributePatterns .add (attributes );
103
- return this ;
104
- }
105
-
106
- @ Override
107
- public Builder addResolvableAttributePattern (
108
- CelAttributePattern attribute , CelUnknownAttributeValueResolver resolver ) {
109
- unknownAttributeResolvers .put (attribute , resolver );
110
- unknownAttributePatterns .add (attribute );
111
- return this ;
112
- }
113
-
114
85
@ Override
115
86
public Builder setMaxEvaluateIterations (int n ) {
116
87
Preconditions .checkArgument (n > 0 , "maxEvaluateIterations must be positive" );
@@ -134,8 +105,6 @@ public Builder setExecutorService(ExecutorService executorService) {
134
105
public CelAsyncRuntime build () {
135
106
Preconditions .checkNotNull (executorService , "executorService must be specified." );
136
107
return new CelAsyncRuntimeImpl (
137
- unknownAttributeResolvers .buildOrThrow (),
138
- unknownAttributePatterns .build (),
139
108
variableResolver .orElse ((unused ) -> Optional .empty ()),
140
109
runtime ,
141
110
executorService ,
0 commit comments