use of com.walmartlabs.concord.runtime.v2.model.TaskCallOptions in project concord by walmartlabs.
the class TaskCallCommand method execute.
@Override
protected void execute(Runtime runtime, State state, ThreadId threadId) {
Frame frame = state.peekFrame(threadId);
frame.pop();
Context ctx = runtime.getService(Context.class);
TaskProviders taskProviders = runtime.getService(TaskProviders.class);
ExpressionEvaluator expressionEvaluator = runtime.getService(ExpressionEvaluator.class);
TaskCall call = getStep();
String taskName = call.getName();
Task t = taskProviders.createTask(ctx, taskName);
if (t == null) {
throw new IllegalStateException("Task not found: '" + taskName + "'");
}
TaskCallInterceptor interceptor = runtime.getService(TaskCallInterceptor.class);
CallContext callContext = CallContext.builder().taskName(taskName).correlationId(ctx.execution().correlationId()).currentStep(getStep()).processDefinition(ctx.execution().processDefinition()).build();
TaskCallOptions opts = Objects.requireNonNull(call.getOptions());
Variables input = new MapBackedVariables(VMUtils.prepareInput(expressionEvaluator, ctx, opts.input(), opts.inputExpression()));
TaskResult result;
try {
result = interceptor.invoke(callContext, Method.of(t, "execute", Collections.singletonList(input)), () -> t.execute(input));
} catch (TaskException e) {
result = TaskResult.fail(e.getCause());
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
TaskCallUtils.processTaskResult(runtime, ctx, taskName, opts, result);
}
use of com.walmartlabs.concord.runtime.v2.model.TaskCallOptions in project concord by walmartlabs.
the class TaskCallStepSerializer method serialize.
@Override
public void serialize(TaskCall value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeStartObject();
TaskCallOptions o = Objects.requireNonNull(value.getOptions());
if ("log".equals(value.getName())) {
gen.writeObjectField("log", o.input().get("msg"));
} else {
gen.writeObjectField("task", value.getName());
writeNotEmptyObjectField("in", o.input(), gen);
writeNotEmptyObjectField("in", o.inputExpression(), gen);
}
writeNotEmptyObjectField("out", o.out(), gen);
writeNotEmptyObjectField("out", o.outExpr(), gen);
if (o.withItems() != null) {
WithItems items = Objects.requireNonNull(o.withItems());
writeWithItems(items, gen);
}
writeLoop(o.loop(), gen);
if (o.retry() != null) {
gen.writeObjectField("retry", o.retry());
}
writeNotEmptyObjectField("error", o.errorSteps(), gen);
writeNotEmptyObjectField("meta", o.meta(), gen);
if (o.ignoreErrors()) {
gen.writeObjectField("ignoreErrors", o.ignoreErrors());
}
gen.writeEndObject();
}
Aggregations