Skip to content

Commit c6f41d7

Browse files
authored
add start workflow async grpc API (#700)
1 parent 1551866 commit c6f41d7

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

src/main/java/com/uber/cadence/internal/compatibility/Thrift2ProtoAdapter.java

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,34 +1026,42 @@ public void StartWorkflowExecutionWithTimeout(
10261026
AsyncMethodCallback resultHandler,
10271027
Long timeoutInMillis)
10281028
throws TException {
1029-
startRequest.setRequestId(UUID.randomUUID().toString());
1030-
ListenableFuture<com.uber.cadence.api.v1.StartWorkflowExecutionResponse> resultFuture =
1031-
grpcServiceStubs
1032-
.workflowFutureStub()
1033-
.withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1034-
.startWorkflowExecution(RequestMapper.startWorkflowExecutionRequest(startRequest));
1035-
resultFuture.addListener(
1036-
() -> {
1037-
try {
1038-
com.uber.cadence.api.v1.StartWorkflowExecutionResponse response = resultFuture.get();
1039-
resultHandler.onComplete(ResponseMapper.startWorkflowExecutionResponse(response));
1040-
} catch (Exception e) {
1041-
resultHandler.onError(e);
1042-
}
1043-
},
1044-
ForkJoinPool.commonPool());
1029+
try {
1030+
startRequest.setRequestId(UUID.randomUUID().toString());
1031+
ListenableFuture<com.uber.cadence.api.v1.StartWorkflowExecutionResponse> resultFuture =
1032+
grpcServiceStubs
1033+
.workflowFutureStub()
1034+
.withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1035+
.startWorkflowExecution(RequestMapper.startWorkflowExecutionRequest(startRequest));
1036+
resultFuture.addListener(
1037+
() -> {
1038+
try {
1039+
com.uber.cadence.api.v1.StartWorkflowExecutionResponse response = resultFuture.get();
1040+
resultHandler.onComplete(ResponseMapper.startWorkflowExecutionResponse(response));
1041+
} catch (Exception e) {
1042+
resultHandler.onError(e);
1043+
}
1044+
},
1045+
ForkJoinPool.commonPool());
1046+
} catch (StatusRuntimeException e) {
1047+
throw ErrorMapper.Error(e);
1048+
}
10451049
}
10461050

10471051
@Override
10481052
public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
10491053
GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) throws TException {
1050-
com.uber.cadence.api.v1.GetWorkflowExecutionHistoryResponse response =
1051-
grpcServiceStubs
1052-
.workflowBlockingStub()
1053-
.withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1054-
.getWorkflowExecutionHistory(
1055-
RequestMapper.getWorkflowExecutionHistoryRequest(getRequest));
1056-
return ResponseMapper.getWorkflowExecutionHistoryResponse(response);
1054+
try {
1055+
com.uber.cadence.api.v1.GetWorkflowExecutionHistoryResponse response =
1056+
grpcServiceStubs
1057+
.workflowBlockingStub()
1058+
.withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1059+
.getWorkflowExecutionHistory(
1060+
RequestMapper.getWorkflowExecutionHistoryRequest(getRequest));
1061+
return ResponseMapper.getWorkflowExecutionHistoryResponse(response);
1062+
} catch (StatusRuntimeException e) {
1063+
throw ErrorMapper.Error(e);
1064+
}
10571065
}
10581066

10591067
@Override

0 commit comments

Comments
 (0)