Package io.kestra.core.runners
Class RunContext
java.lang.Object
io.kestra.core.runners.RunContext
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRunContext(io.micronaut.context.ApplicationContext applicationContext, Flow flow, Execution execution) Only used byFlowRunContext(io.micronaut.context.ApplicationContext applicationContext, Flow flow, Task task, Execution execution, TaskRun taskRun) Normal usageRunContext(io.micronaut.context.ApplicationContext applicationContext, Flow flow, AbstractTrigger trigger) Only used byAbstractTrigger, then scheduler must callforScheduler(TriggerContext, AbstractTrigger)RunContext(io.micronaut.context.ApplicationContext applicationContext, Map<String, Object> variables) Only used by Unit Test -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()deleteTaskCacheFile(String namespace, String flowId, String taskId, String value) booleandeleteTaskStateFile(String state, String name) booleandeleteTaskStateFile(String state, String name, Boolean isNamespace, Boolean useTaskRun) voiddynamicWorkerResult(List<WorkerTaskResult> workerTaskResults) fileExtension(String fileName) Get the file extension including the '.' to be used with the various methods that took a suffix.forScheduler(TriggerContext triggerContext, AbstractTrigger trigger) forWorker(io.micronaut.context.ApplicationContext applicationContext, WorkerTask workerTask) forWorker(io.micronaut.context.ApplicationContext applicationContext, WorkerTrigger workerTrigger) forWorkerDirectory(io.micronaut.context.ApplicationContext applicationContext, WorkerTask workerTask) io.micronaut.context.ApplicationContextgetTaskCacheFile(String namespace, String flowId, String taskId, String value) Get from the internal storage the cache file corresponding to this task.getTaskCacheFileLastModifiedTime(String namespace, String flowId, String taskId, String value) getTaskStateFile(String state, String name) getTaskStateFile(String state, String name, Boolean isNamespace, Boolean useTaskRun) protected voidinitBean(io.micronaut.context.ApplicationContext applicationContext) org.slf4j.Loggerlogger()<T> RunContextmetric(AbstractMetricEntry<T> metricEntry) metrics()Put into the internal storage the cache file corresponding to this task.putTaskStateFile(byte[] content, String state, String name) putTaskStateFile(byte[] content, String state, String name, Boolean namespace, Boolean useTaskRun) putTaskStateFile(File file, String state, String name) putTempFile(File file) Put the temporary file on storage and delete it after.putTempFile(File file, String name) Put the temporary file on storage and delete it after.putTempFile(File file, String executionId, AbstractTrigger trigger) Put the temporary file on storage and delete it after.tempDir()tempDir(boolean create) tempFile()Deprecated.tempFile(byte[] content) Deprecated.usetempFile(byte[], String)insteadupdateVariables(WorkerTaskResult workerTaskResult, TaskRun parent) uriToInputStream(URI uri)
-
Field Details
-
temporaryDirectory
-
-
Constructor Details
-
RunContext
public RunContext(io.micronaut.context.ApplicationContext applicationContext, Flow flow, Execution execution) Only used byFlow -
RunContext
public RunContext(io.micronaut.context.ApplicationContext applicationContext, Flow flow, Task task, Execution execution, TaskRun taskRun) Normal usage -
RunContext
public RunContext(io.micronaut.context.ApplicationContext applicationContext, Flow flow, AbstractTrigger trigger) Only used byAbstractTrigger, then scheduler must callforScheduler(TriggerContext, AbstractTrigger)- Parameters:
applicationContext- the currentApplicationContext
-
RunContext
public RunContext(io.micronaut.context.ApplicationContext applicationContext, Map<String, Object> variables) Only used by Unit Test- Parameters:
applicationContext- the currentApplicationContextvariables- The variable to inject
-
-
Method Details
-
initBean
protected void initBean(io.micronaut.context.ApplicationContext applicationContext) -
getTriggerExecutionId
-
getVariables
-
getStorageOutputPrefix
-
getApplicationContext
public io.micronaut.context.ApplicationContext getApplicationContext() -
variables
-
updateVariables
-
forScheduler
-
forWorker
public RunContext forWorker(io.micronaut.context.ApplicationContext applicationContext, WorkerTask workerTask) -
forWorker
public RunContext forWorker(io.micronaut.context.ApplicationContext applicationContext, WorkerTrigger workerTrigger) -
forWorkerDirectory
public RunContext forWorkerDirectory(io.micronaut.context.ApplicationContext applicationContext, WorkerTask workerTask) -
render
-
render
-
render
-
render
-
render
-
render
-
render
-
render
-
renderMap
-
logger
public org.slf4j.Logger logger() -
uriToInputStream
- Throws:
IOException
-
putTempFile
Put the temporary file on storage and delete it after.- Parameters:
file- the temporary file to upload to storage- Returns:
- the
StorageObjectcreated - Throws:
IOException- If the temporary file can't be read
-
putTempFile
Put the temporary file on storage and delete it after.- Parameters:
file- the temporary file to upload to storagename- overwrite file name- Returns:
- the
StorageObjectcreated - Throws:
IOException- If the temporary file can't be read
-
putTempFile
Put the temporary file on storage and delete it after. This method is meant to be used by polling triggers, the name of the destination file is derived from the executionId and the trigger passed as parameters.- Parameters:
file- the temporary file to upload to storageexecutionId- overwrite file nametrigger- the trigger- Returns:
- the
StorageObjectcreated - Throws:
IOException- If the temporary file can't be read
-
getTaskStateFile
- Throws:
IOException
-
getTaskStateFile
public InputStream getTaskStateFile(String state, String name, Boolean isNamespace, Boolean useTaskRun) throws IOException - Throws:
IOException
-
putTaskStateFile
- Throws:
IOException
-
putTaskStateFile
public URI putTaskStateFile(byte[] content, String state, String name, Boolean namespace, Boolean useTaskRun) throws IOException - Throws:
IOException
-
putTaskStateFile
- Throws:
IOException
-
putTaskStateFile
public URI putTaskStateFile(File file, String state, String name, Boolean isNamespace, Boolean useTaskRun) throws IOException - Throws:
IOException
-
deleteTaskStateFile
- Throws:
IOException
-
deleteTaskStateFile
public boolean deleteTaskStateFile(String state, String name, Boolean isNamespace, Boolean useTaskRun) throws IOException - Throws:
IOException
-
getTaskCacheFile
public Optional<InputStream> getTaskCacheFile(String namespace, String flowId, String taskId, String value) throws IOException Get from the internal storage the cache file corresponding to this task. If the cache file didn't exist, an empty Optional is returned.- Parameters:
namespace- the flow namespaceflowId- the flow identifiertaskId- the task identifiervalue- optional, the task run value- Returns:
- an Optional with the cache input stream or empty.
- Throws:
IOException
-
getTaskCacheFileLastModifiedTime
public Optional<Long> getTaskCacheFileLastModifiedTime(String namespace, String flowId, String taskId, String value) throws IOException - Throws:
IOException
-
putTaskCacheFile
public URI putTaskCacheFile(File file, String namespace, String flowId, String taskId, String value) throws IOException Put into the internal storage the cache file corresponding to this task.- Parameters:
file- the cache as a ZIP archivenamespace- the flow namespaceflowId- the flow identifiertaskId- the task identifiervalue- optional, the task run value- Returns:
- the URI of the file inside the internal storage.
- Throws:
IOException
-
deleteTaskCacheFile
public Optional<Boolean> deleteTaskCacheFile(String namespace, String flowId, String taskId, String value) throws IOException - Throws:
IOException
-
purgeStorageExecution
- Throws:
IOException
-
metrics
-
metric
-
dynamicWorkerResult
-
dynamicWorkerResults
-
tempDir
-
tempDir
-
tempFile
Deprecated.usetempFile(String)instead- Throws:
IOException
-
tempFile
- Throws:
IOException
-
tempFile
Deprecated.usetempFile(byte[], String)instead- Throws:
IOException
-
tempFile
- Throws:
IOException
-
fileExtension
Get the file extension including the '.' to be used with the various methods that took a suffix.- Parameters:
fileName- the name of the file- Returns:
- the file extension including the '.' or null
-
cleanup
public void cleanup()
-
tempFile(String)instead