use of com.uber.cadence.QueryWorkflowResponse in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method completeQuery.
@Override
public void completeQuery(QueryId queryId, RespondQueryTaskCompletedRequest completeRequest) throws EntityNotExistsError {
CompletableFuture<QueryWorkflowResponse> result = queries.get(queryId.getQueryId());
if (result == null) {
throw new EntityNotExistsError("Unknown query id: " + queryId.getQueryId());
}
if (completeRequest.getCompletedType() == QueryTaskCompletedType.COMPLETED) {
QueryWorkflowResponse response = new QueryWorkflowResponse().setQueryResult(completeRequest.getQueryResult());
result.complete(response);
} else {
QueryFailedError error = new QueryFailedError().setMessage(completeRequest.getErrorMessage());
result.completeExceptionally(error);
}
}
use of com.uber.cadence.QueryWorkflowResponse in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method query.
@Override
public QueryWorkflowResponse query(QueryWorkflowRequest queryRequest) throws TException {
QueryId queryId = new QueryId(executionId);
PollForDecisionTaskResponse task = new PollForDecisionTaskResponse().setTaskToken(queryId.toBytes()).setWorkflowExecution(executionId.getExecution()).setWorkflowType(startRequest.getWorkflowType()).setQuery(queryRequest.getQuery());
TaskListId taskListId = new TaskListId(queryRequest.getDomain(), startRequest.getTaskList().getName());
store.sendQueryTask(executionId, taskListId, task);
CompletableFuture<QueryWorkflowResponse> result = new CompletableFuture<>();
queries.put(queryId.getQueryId(), result);
try {
return result.get();
} catch (InterruptedException e) {
return new QueryWorkflowResponse();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof TException) {
throw (TException) cause;
}
throw new InternalServiceError(Throwables.getStackTraceAsString(cause));
}
}
use of com.uber.cadence.QueryWorkflowResponse in project cadence-client by uber-java.
the class GenericWorkflowClientExternalImpl method queryWorkflow.
@Override
public byte[] queryWorkflow(QueryWorkflowParameters queryParameters) {
QueryWorkflowRequest request = new QueryWorkflowRequest();
request.setDomain(domain);
WorkflowExecution execution = new WorkflowExecution();
execution.setWorkflowId(queryParameters.getWorkflowId()).setRunId(queryParameters.getRunId());
request.setExecution(execution);
WorkflowQuery query = new WorkflowQuery();
query.setQueryArgs(queryParameters.getInput());
query.setQueryType(queryParameters.getQueryType());
request.setQuery(query);
try {
QueryWorkflowResponse response = service.QueryWorkflow(request);
return response.getQueryResult();
} catch (TException e) {
throw CheckedExceptionWrapper.wrap(e);
}
}
Aggregations