|
31 | 31 | import io.iworkflow.gen.models.WorkflowStartResponse;
|
32 | 32 | import io.iworkflow.gen.models.WorkflowStatus;
|
33 | 33 | import io.iworkflow.gen.models.WorkflowStopRequest;
|
| 34 | +import io.iworkflow.gen.models.WorkflowWaitForStateCompletionRequest; |
| 35 | +import io.iworkflow.gen.models.WorkflowWaitForStateCompletionResponse; |
34 | 36 |
|
35 | 37 | import java.util.List;
|
36 | 38 | import java.util.stream.Collectors;
|
@@ -152,6 +154,8 @@ public String startWorkflow(
|
152 | 154 | }
|
153 | 155 |
|
154 | 156 | request.workflowStartOptions(startOptions);
|
| 157 | + |
| 158 | + request.waitForCompletionStateExecutionIds(options.getWaitForCompletionStateExecutionIds()); |
155 | 159 | }
|
156 | 160 |
|
157 | 161 | try {
|
@@ -341,6 +345,26 @@ private List<StateCompletionOutput> getWorkflowResults(
|
341 | 345 | return results;
|
342 | 346 | }
|
343 | 347 |
|
| 348 | + public <T> T waitForStateExecutionCompletion( |
| 349 | + final Class<T> valueClass, |
| 350 | + final String workflowId, |
| 351 | + final String stateExecutionId) { |
| 352 | + final WorkflowWaitForStateCompletionRequest request = new WorkflowWaitForStateCompletionRequest() |
| 353 | + .stateExecutionId(stateExecutionId) |
| 354 | + .workflowId(workflowId); |
| 355 | + final WorkflowWaitForStateCompletionResponse response; |
| 356 | + try { |
| 357 | + response = defaultApi.apiV1WorkflowWaitForStateCompletionPost(request); |
| 358 | + } catch (final FeignException.FeignClientException exp) { |
| 359 | + throw IwfHttpException.fromFeignException(clientOptions.getObjectEncoder(), exp); |
| 360 | + } |
| 361 | + |
| 362 | + if (response.getStateCompletionOutput() == null) { |
| 363 | + return null; |
| 364 | + } |
| 365 | + return clientOptions.getObjectEncoder().decode(response.getStateCompletionOutput().getCompletedStateOutput(), valueClass); |
| 366 | + } |
| 367 | + |
344 | 368 | private void throwUncompletedException(final WorkflowGetResponse workflowGetResponse) {
|
345 | 369 | throw new WorkflowUncompletedException(
|
346 | 370 | workflowGetResponse.getWorkflowRunId(),
|
|
0 commit comments