17
17
18
18
package com .uber .cadence .client ;
19
19
20
+ import com .uber .cadence .QueryRejectCondition ;
20
21
import com .uber .cadence .context .ContextPropagator ;
21
22
import com .uber .cadence .converter .DataConverter ;
22
23
import com .uber .cadence .converter .JsonDataConverter ;
@@ -60,6 +61,7 @@ public static final class Builder {
60
61
private Scope metricsScope = NoopScope .getInstance ();
61
62
private String identity = ManagementFactory .getRuntimeMXBean ().getName ();;
62
63
private List <ContextPropagator > contextPropagators = EMPTY_CONTEXT_PROPAGATORS ;
64
+ private QueryRejectCondition queryRejectCondition ;
63
65
64
66
private Builder () {}
65
67
@@ -69,6 +71,7 @@ private Builder(WorkflowClientOptions options) {
69
71
interceptors = options .getInterceptors ();
70
72
metricsScope = options .getMetricsScope ();
71
73
identity = options .getIdentity ();
74
+ queryRejectCondition = options .getQueryRejectCondition ();
72
75
}
73
76
74
77
public Builder setDomain (String domain ) {
@@ -123,33 +126,55 @@ public Builder setContextPropagators(List<ContextPropagator> contextPropagators)
123
126
return this ;
124
127
}
125
128
129
+ /**
130
+ * QueryRejectCondition is an optional field used to reject queries based on workflow state.
131
+ * QueryRejectConditionNotOpen will reject queries to workflows that are not open.
132
+ * QueryRejectConditionNotCompletedCleanly will reject queries to workflows that are not
133
+ * completed successfully. (e.g. terminated, canceled timeout etc...)
134
+ *
135
+ * <p>Default is null, which means that queries will not be rejected based on workflow state.
136
+ */
137
+ public Builder setQueryRejectCondition (QueryRejectCondition queryRejectCondition ) {
138
+ this .queryRejectCondition = queryRejectCondition ;
139
+ return this ;
140
+ }
141
+
126
142
public WorkflowClientOptions build () {
127
143
metricsScope = metricsScope .tagged (ImmutableMap .of (MetricsTag .DOMAIN , domain ));
128
144
return new WorkflowClientOptions (
129
- domain , dataConverter , interceptors , metricsScope , identity , contextPropagators );
145
+ domain ,
146
+ dataConverter ,
147
+ interceptors ,
148
+ metricsScope ,
149
+ identity ,
150
+ contextPropagators ,
151
+ queryRejectCondition );
130
152
}
131
153
}
132
154
133
155
private final String domain ;
134
156
private final DataConverter dataConverter ;
135
157
private final WorkflowClientInterceptor [] interceptors ;
136
158
private final Scope metricsScope ;
137
- private String identity ;
138
- private List <ContextPropagator > contextPropagators ;
159
+ private final String identity ;
160
+ private final List <ContextPropagator > contextPropagators ;
161
+ private final QueryRejectCondition queryRejectCondition ;
139
162
140
163
private WorkflowClientOptions (
141
164
String domain ,
142
165
DataConverter dataConverter ,
143
166
WorkflowClientInterceptor [] interceptors ,
144
167
Scope metricsScope ,
145
168
String identity ,
146
- List <ContextPropagator > contextPropagators ) {
169
+ List <ContextPropagator > contextPropagators ,
170
+ QueryRejectCondition queryRejectCondition ) {
147
171
this .domain = domain ;
148
172
this .dataConverter = dataConverter ;
149
173
this .interceptors = interceptors ;
150
174
this .metricsScope = metricsScope ;
151
175
this .identity = identity ;
152
176
this .contextPropagators = contextPropagators ;
177
+ this .queryRejectCondition = queryRejectCondition ;
153
178
}
154
179
155
180
public String getDomain () {
@@ -175,4 +200,52 @@ public String getIdentity() {
175
200
public List <ContextPropagator > getContextPropagators () {
176
201
return contextPropagators ;
177
202
}
203
+
204
+ public QueryRejectCondition getQueryRejectCondition () {
205
+ return queryRejectCondition ;
206
+ }
207
+
208
+ @ Override
209
+ public String toString () {
210
+ return "WorkflowClientOptions{"
211
+ + "domain='"
212
+ + domain
213
+ + '\''
214
+ + ", dataConverter="
215
+ + dataConverter
216
+ + ", interceptors="
217
+ + Arrays .toString (interceptors )
218
+ + ", identity='"
219
+ + identity
220
+ + '\''
221
+ + ", contextPropagators="
222
+ + contextPropagators
223
+ + ", queryRejectCondition="
224
+ + queryRejectCondition
225
+ + '}' ;
226
+ }
227
+
228
+ @ Override
229
+ public boolean equals (Object o ) {
230
+ if (this == o ) return true ;
231
+ if (o == null || getClass () != o .getClass ()) return false ;
232
+ WorkflowClientOptions that = (WorkflowClientOptions ) o ;
233
+ return com .google .common .base .Objects .equal (domain , that .domain )
234
+ && com .google .common .base .Objects .equal (dataConverter , that .dataConverter )
235
+ && Arrays .equals (interceptors , that .interceptors )
236
+ && com .google .common .base .Objects .equal (identity , that .identity )
237
+ && com .google .common .base .Objects .equal (contextPropagators , that .contextPropagators )
238
+ && queryRejectCondition == that .queryRejectCondition ;
239
+ }
240
+
241
+ @ Override
242
+ public int hashCode () {
243
+ return com .google .common .base .Objects .hashCode (
244
+ domain ,
245
+ dataConverter ,
246
+ Arrays .hashCode (interceptors ),
247
+ identity ,
248
+ contextPropagators ,
249
+ queryRejectCondition );
250
+ }
178
251
}
0 commit comments