Skip to content

aupadhyay3/workflow-prototype-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

workflow-prototype-java

About

A Java prototype for Kubernetes-native Nirmata workflows. WorkflowApp watches WorkflowTask Kubernetes custom resources and executes user-defined Java tasks upon resource creation. Tasks of different types may be assigned individually to different executors and run in parallel.

A Golang implementation can be found here.

Usage

To create a new WorkflowApp, use the builder:

WorkflowApp workflowApp = WorkflowAppBuilder.builder();

Required: A fabric8 KubernetesClient and a namespace string must be specified using the builder.

WorkflowApp workflowApp = WorkflowAppBuilder.builder()
    .withClient(client)
    .withNamespace(namespace);

Finally, add tasks and executors. WorkflowApp.addTaskExecutor() takes in two parameters: a Task implementing the Task interface and an integer thread pool size. Using this method, tasks are executed by a ThreadPoolExecutor that terminates threads that have been idle for 60 seconds.

WorkflowApp workflowApp = WorkflowAppBuilder.builder()
    .withClient(client)
    .withNamespace(namespace)
    .addTaskExecutor(task, threadPoolSize)
    .build();

The thread timeout may also be specified:

WorkflowApp workflowApp = WorkflowAppBuilder.builder()
    .withClient(client)
    .withNamespace(namespace)
    .addTaskExecutor(task, threadPoolSize, threadKeepAliveTime, timeUnit)
    .build();

Any existing Executor can also be passed in instead:

WorkflowApp workflowApp = WorkflowAppBuilder.builder()
    .withClient(client)
    .withNamespace(namespace)
    .addTaskExecutor(task, executor)
    .build();

Finally, start the WorkflowApp:

workflowApp.start();

The Task interface contains two methods: execute() and getType(). execute() takes in a WorkflowTask POJO and performs the task execution, possibly throwing an Exception. getType() returns the type of the task as a string.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published