Class OrchestratorEngine
java.lang.Object
com.iantapply.orchestra.engine.OrchestratorEngine
- All Implemented Interfaces:
AutoCloseable
Durable, at-least-once orchestration engine. Action implementations should use
ActionContext.idempotencyKey() when calling systems that support deduplication.-
Constructor Summary
ConstructorsConstructorDescriptionOrchestratorEngine(DefinitionRepository definitions, ExecutionRepository executions, DistributedLock locks, TargetResolver targets, ActionRegistry registry, Clock clock, int workerCount, int queueCapacity) Creates an engine with bounded worker concurrency and queue capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(EventLifecycleListener listener) Registers a lifecycle listener.booleanCancels an execution.voidclose()Stops polling and shuts down engine workers.booleanPauses an execution.voidrecover()Immediately scans persisted state; called on startup to recover interrupted work.booleanResumes an execution.booleanReschedules a failed execution from its first stage.Creates a durable execution for a known definition.booleansetVariable(UUID id, String key, Object value) Atomically sets or removes an execution variable.voidstart()Starts the due-execution polling loop once.Schedules an event immediately with no initial variables.
-
Constructor Details
-
OrchestratorEngine
public OrchestratorEngine(DefinitionRepository definitions, ExecutionRepository executions, DistributedLock locks, TargetResolver targets, ActionRegistry registry, Clock clock, int workerCount, int queueCapacity) Creates an engine with bounded worker concurrency and queue capacity.- Parameters:
definitions- event definition storeexecutions- durable execution storelocks- distributed execution lease providertargets- target resolverregistry- action and condition registryclock- engine clockworkerCount- number of concurrent execution workersqueueCapacity- maximum queued execution tasks
-
-
Method Details
-
start
public void start()Starts the due-execution polling loop once. -
schedule
Creates a durable execution for a known definition.- Parameters:
definitionId- event definition identifierstartAt- requested start timevariables- initial execution variables- Returns:
- new execution identifier
-
startNow
-
addListener
Registers a lifecycle listener.- Parameters:
listener- lifecycle listener retained until the engine closes
-
pause
Pauses an execution.- Parameters:
id- execution identifier- Returns:
- whether the execution was found and atomically paused
-
resume
Resumes an execution.- Parameters:
id- execution identifier- Returns:
- whether the execution was found and atomically resumed
-
cancel
Cancels an execution.- Parameters:
id- execution identifier- Returns:
- whether the execution was found and atomically cancelled
-
retry
Reschedules a failed execution from its first stage.- Parameters:
id- execution identifier- Returns:
- whether the failed execution was atomically rescheduled
-
setVariable
-
recover
public void recover()Immediately scans persisted state; called on startup to recover interrupted work. -
close
public void close()Stops polling and shuts down engine workers.- Specified by:
closein interfaceAutoCloseable
-