use of com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration in project concord by walmartlabs.
the class FormCallCommand method execute.
@Override
protected void execute(Runtime runtime, State state, ThreadId threadId) {
String eventRef = UUID.randomUUID().toString();
Context ctx = runtime.getService(Context.class);
ExpressionEvaluator expressionEvaluator = runtime.getService(ExpressionEvaluator.class);
EvalContext evalContext = EvalContextFactory.global(ctx);
FormCall call = getStep();
String formName = expressionEvaluator.eval(evalContext, call.getName(), String.class);
ProcessDefinition processDefinition = runtime.getService(ProcessDefinition.class);
ProcessConfiguration processConfiguration = runtime.getService(ProcessConfiguration.class);
List<FormField> fields = assertFormFields(expressionEvaluator, evalContext, processConfiguration, processDefinition, formName, call);
Form form = Form.builder().name(formName).eventName(eventRef).options(buildFormOptions(expressionEvaluator, evalContext, call)).fields(buildFormFields(expressionEvaluator, evalContext, fields, Objects.requireNonNull(call.getOptions()).values())).build();
FormService formService = runtime.getService(FormService.class);
formService.save(form);
state.peekFrame(threadId).pop();
state.setEventRef(threadId, eventRef);
state.setStatus(threadId, ThreadStatus.SUSPENDED);
}
use of com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration in project concord by walmartlabs.
the class InjectorFactory method createDefault.
public static Injector createDefault(RunnerConfiguration runnerCfg) {
Path src = Paths.get(System.getProperty("user.dir"));
Provider<ProcessConfiguration> processCfgProvider = new DefaultProcessConfigurationProvider(src);
WorkingDirectory workDir = new WorkingDirectory(src);
return new InjectorFactory(workDir, runnerCfg, processCfgProvider, // bind default services
new DefaultRunnerModule(), // grab process dependencies
new ProcessDependenciesModule(workDir.getValue(), runnerCfg.dependencies(), runnerCfg.debug())).create();
}
use of com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration in project concord by walmartlabs.
the class Main method main.
public static void main(String[] args) throws Exception {
RunnerConfiguration runnerCfg = readRunnerConfiguration(args);
// create the inject with all dependencies and services available before
// the actual process' working directory is ready. It allows us to load
// all dependencies and have them available in "pre-fork" situations
Injector injector = InjectorFactory.createDefault(runnerCfg);
try {
ProcessConfiguration processCfg = injector.getInstance(ProcessConfiguration.class);
ApiClient apiClient = injector.getInstance(ApiClient.class);
ProcessHeartbeat heartbeat = new ProcessHeartbeat(apiClient, processCfg.instanceId(), runnerCfg.api().maxNoHeartbeatInterval());
heartbeat.start();
Main main = injector.getInstance(Main.class);
main.execute();
System.exit(0);
} catch (MultiException e) {
log.error(e.getMessage());
System.exit(1);
} catch (Throwable t) {
log.error("", t);
System.exit(1);
}
}
use of com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration in project concord by walmartlabs.
the class Main method start.
private static ProcessSnapshot start(Runner runner, ProcessConfiguration cfg, Path workDir, Map<String, Object> args) throws Exception {
// assume all imports were processed by the agent
ProjectLoaderV2 loader = new ProjectLoaderV2(new NoopImportManager());
ProcessDefinition processDefinition = loader.load(workDir, new NoopImportsNormalizer(), ImportsListener.NOP_LISTENER).getProjectDefinition();
Map<String, Object> initiator = cfg.initiator();
if (initiator != null) {
// when the process starts the process' initiator and the current user are the same
args.put(Constants.Request.INITIATOR_KEY, initiator);
args.put(Constants.Request.CURRENT_USER_KEY, initiator);
}
return runner.start(cfg, processDefinition, args);
}
use of com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration in project concord by walmartlabs.
the class Runner method start.
public ProcessSnapshot start(ProcessConfiguration processConfiguration, ProcessDefinition processDefinition, Map<String, Object> input) throws Exception {
statusCallback.onRunning(instanceId.getValue());
log.debug("start ['{}'] -> running...", processConfiguration.entryPoint());
Command cmd = CompilerUtils.compile(compiler, processConfiguration, processDefinition, processConfiguration.entryPoint());
State state = new InMemoryState(cmd);
// install the exception handler into the root frame
// takes care of all unhandled errors bubbling up
VMUtils.assertNearestRoot(state, state.getRootThreadId()).setExceptionHandler(new SaveLastErrorCommand());
VM vm = createVM(processDefinition);
// update the global variables using the input map by running a special command
// TODO merge with the cfg's arguments
vm.run(state, new UpdateLocalsCommand(input));
// start the normal execution
vm.start(state);
log.debug("start ['{}'] -> done", processConfiguration.entryPoint());
return ProcessSnapshot.builder().vmState(state).processDefinition(processDefinition).build();
}
Aggregations