@@ -823,19 +823,28 @@ private StartWorkflowExecutionResponse startWorkflowExecution(
823
823
}
824
824
}
825
825
826
+ @ Override
827
+ public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout (
828
+ GetWorkflowExecutionHistoryRequest request , Long timeoutInMillis ) throws TException {
829
+ return measureRemoteCall (
830
+ ServiceMethod .GET_WORKFLOW_EXECUTION_HISTORY ,
831
+ () -> getWorkflowExecutionHistory (request , timeoutInMillis ));
832
+ }
833
+
826
834
@ Override
827
835
public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory (
828
836
GetWorkflowExecutionHistoryRequest request ) throws TException {
829
837
return measureRemoteCall (
830
- ServiceMethod .GET_WORKFLOW_EXECUTION_HISTORY , () -> getWorkflowExecutionHistory (request ));
838
+ ServiceMethod .GET_WORKFLOW_EXECUTION_HISTORY ,
839
+ () -> getWorkflowExecutionHistory (request , null ));
831
840
}
832
841
833
842
private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory (
834
- GetWorkflowExecutionHistoryRequest getRequest ) throws TException {
843
+ GetWorkflowExecutionHistoryRequest getRequest , Long timeoutInMillis ) throws TException {
835
844
ThriftResponse <WorkflowService .GetWorkflowExecutionHistory_result > response = null ;
836
845
try {
837
846
ThriftRequest <WorkflowService .GetWorkflowExecutionHistory_args > request =
838
- buildGetWorkflowExecutionHistoryThriftRequest (getRequest );
847
+ buildGetWorkflowExecutionHistoryThriftRequest (getRequest , timeoutInMillis );
839
848
response = doRemoteCall (request );
840
849
WorkflowService .GetWorkflowExecutionHistory_result result =
841
850
response .getBody (WorkflowService .GetWorkflowExecutionHistory_result .class );
@@ -870,21 +879,20 @@ private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
870
879
}
871
880
872
881
private ThriftRequest <WorkflowService .GetWorkflowExecutionHistory_args >
873
- buildGetWorkflowExecutionHistoryThriftRequest (GetWorkflowExecutionHistoryRequest getRequest ) {
874
- ThriftRequest <WorkflowService .GetWorkflowExecutionHistory_args > request ;
882
+ buildGetWorkflowExecutionHistoryThriftRequest (
883
+ GetWorkflowExecutionHistoryRequest getRequest , Long timeoutInMillis ) {
884
+
875
885
if (getRequest .isWaitForNewEvent ()) {
876
- request =
877
- buildThriftRequest (
878
- "GetWorkflowExecutionHistory" ,
879
- new WorkflowService .GetWorkflowExecutionHistory_args (getRequest ),
880
- options .getRpcLongPollTimeoutMillis ());
886
+ timeoutInMillis =
887
+ validateAndUpdateTimeout (timeoutInMillis , options .getRpcLongPollTimeoutMillis ());
881
888
} else {
882
- request =
883
- buildThriftRequest (
884
- "GetWorkflowExecutionHistory" ,
885
- new WorkflowService .GetWorkflowExecutionHistory_args (getRequest ));
889
+ timeoutInMillis = validateAndUpdateTimeout (timeoutInMillis , options .getRpcTimeoutMillis ());
886
890
}
887
- return request ;
891
+
892
+ return buildThriftRequest (
893
+ "GetWorkflowExecutionHistory" ,
894
+ new WorkflowService .GetWorkflowExecutionHistory_args (getRequest ),
895
+ timeoutInMillis );
888
896
}
889
897
890
898
@ Override
@@ -2297,15 +2305,43 @@ public void StartWorkflowExecution(
2297
2305
throw new UnsupportedOperationException ("not implemented" );
2298
2306
}
2299
2307
2308
+ private Long validateAndUpdateTimeout (Long timeoutInMillis , Long defaultTimeoutInMillis ) {
2309
+ if (timeoutInMillis == null || timeoutInMillis <= 0 || timeoutInMillis == Long .MAX_VALUE ) {
2310
+ timeoutInMillis = defaultTimeoutInMillis ;
2311
+ } else {
2312
+ timeoutInMillis = Math .min (timeoutInMillis , defaultTimeoutInMillis );
2313
+ }
2314
+ return timeoutInMillis ;
2315
+ }
2316
+
2317
+ @ SuppressWarnings ({"unchecked" , "FutureReturnValueIgnored" })
2318
+ @ Override
2319
+ public void GetWorkflowExecutionHistoryWithTimeout (
2320
+ GetWorkflowExecutionHistoryRequest getRequest ,
2321
+ AsyncMethodCallback resultHandler ,
2322
+ Long timeoutInMillis ) {
2323
+
2324
+ getWorkflowExecutionHistory (getRequest , resultHandler , timeoutInMillis );
2325
+ }
2326
+
2300
2327
@ SuppressWarnings ({"unchecked" , "FutureReturnValueIgnored" })
2301
2328
@ Override
2302
2329
public void GetWorkflowExecutionHistory (
2303
2330
GetWorkflowExecutionHistoryRequest getRequest , AsyncMethodCallback resultHandler ) {
2304
- CompletableFuture <ThriftResponse <GetWorkflowExecutionHistory_result >> response = null ;
2331
+
2332
+ getWorkflowExecutionHistory (getRequest , resultHandler , null );
2333
+ }
2334
+
2335
+ private void getWorkflowExecutionHistory (
2336
+ GetWorkflowExecutionHistoryRequest getRequest ,
2337
+ AsyncMethodCallback resultHandler ,
2338
+ Long timeoutInMillis ) {
2339
+
2305
2340
ThriftRequest <WorkflowService .GetWorkflowExecutionHistory_args > request =
2306
- buildGetWorkflowExecutionHistoryThriftRequest (getRequest );
2307
- response = doRemoteCallAsync (request );
2341
+ buildGetWorkflowExecutionHistoryThriftRequest (getRequest , timeoutInMillis );
2308
2342
2343
+ CompletableFuture <ThriftResponse <GetWorkflowExecutionHistory_result >> response =
2344
+ doRemoteCallAsync (request );
2309
2345
response
2310
2346
.whenComplete (
2311
2347
(r , e ) -> {
0 commit comments