use of com.uber.cadence.internal.replay.ExecuteActivityParameters in project cadence-client by uber-java.
the class SyncDecisionContext method executeActivityOnce.
private Promise<byte[]> executeActivityOnce(String name, ActivityOptions options, byte[] input) {
CompletablePromise<byte[]> result = Workflow.newPromise();
ExecuteActivityParameters parameters = new ExecuteActivityParameters();
// TODO: Real task list
String taskList = options.getTaskList();
if (taskList == null) {
taskList = context.getTaskList();
}
parameters.withActivityType(new ActivityType().setName(name)).withInput(input).withTaskList(taskList).withScheduleToStartTimeoutSeconds(options.getScheduleToStartTimeout().getSeconds()).withStartToCloseTimeoutSeconds(options.getStartToCloseTimeout().getSeconds()).withScheduleToCloseTimeoutSeconds(options.getScheduleToCloseTimeout().getSeconds()).setHeartbeatTimeoutSeconds(options.getHeartbeatTimeout().getSeconds());
Consumer<Exception> cancellationCallback = context.scheduleActivityTask(parameters, (output, failure) -> {
if (failure != null) {
runner.executeInWorkflowThread("activity failure callback", () -> result.completeExceptionally(mapActivityException(failure)));
} else {
runner.executeInWorkflowThread("activity completion callback", () -> result.complete(output));
}
});
CancellationScope.current().getCancellationRequest().thenApply((reason) -> {
cancellationCallback.accept(new CancellationException(reason));
return null;
});
return result;
}
Aggregations