use of com.walmartlabs.concord.runtime.v2.model.ScriptCallOptions in project concord by walmartlabs.
the class ScriptCallCommand method execute.
@Override
protected void execute(Runtime runtime, State state, ThreadId threadId) {
state.peekFrame(threadId).pop();
Context ctx = runtime.getService(Context.class);
ExpressionEvaluator expressionEvaluator = runtime.getService(ExpressionEvaluator.class);
ScriptEvaluator scriptEvaluator = runtime.getService(ScriptEvaluator.class);
ResourceResolver resourceResolver = runtime.getService(ResourceResolver.class);
ScriptCall call = getStep();
ScriptCallOptions opts = Objects.requireNonNull(call.getOptions());
Map<String, Object> input = VMUtils.prepareInput(expressionEvaluator, ctx, opts.input(), opts.inputExpression());
String language = getLanguage(expressionEvaluator, scriptEvaluator, ctx, call);
Reader content = getContent(expressionEvaluator, resourceResolver, ctx, call);
ScriptResult scriptResult;
try {
scriptResult = scriptEvaluator.eval(ctx, language, content, input);
} finally {
try {
content.close();
} catch (IOException e) {
// we don't have to do anything about it, but we're going to log the error just in case
log.warn("Error while closing the script's reader: {}", e.getMessage() + ". This is most likely a bug.");
}
}
OutputUtils.process(runtime, ctx, scriptResult.items(), opts.out(), opts.outExpr());
}
use of com.walmartlabs.concord.runtime.v2.model.ScriptCallOptions in project concord by walmartlabs.
the class ScriptCallStepSerializer method serializeOptions.
private static void serializeOptions(ScriptCallOptions options, JsonGenerator gen) throws IOException {
if (options == null) {
return;
}
if (options.body() != null) {
gen.writeObjectField("body", options.body());
}
writeNotEmptyObjectField("in", options.input(), gen);
writeNotEmptyObjectField("in", options.inputExpression(), gen);
writeNotEmptyObjectField("out", options.out(), gen);
writeNotEmptyObjectField("out", options.outExpr(), gen);
if (options.withItems() != null) {
WithItems items = Objects.requireNonNull(options.withItems());
writeWithItems(items, gen);
}
writeLoop(options.loop(), gen);
if (options.retry() != null) {
gen.writeObjectField("retry", options.retry());
}
writeNotEmptyObjectField("error", options.errorSteps(), gen);
writeNotEmptyObjectField("meta", options.meta(), gen);
}
Aggregations