A lightweight Java library for orchestrating task DAGs with virtual threads.
Project details
AdaptiveFlow offers a zero-runtime-dependency solution for building and executing task Directed Acyclic Graphs (DAGs) on Java 21's Virtual Threads. With a simplistic and fluent API, it eliminates the need for heavy frameworks, allowing tasks to be managed with minimal overhead. Experience seamless workflow orchestration with this efficient library.
AdaptiveFlow is a lightweight Java 21 library designed to execute task directed acyclic graphs (DAGs) using Virtual Threads without any runtime dependencies. This library enables efficient workflow orchestration by providing a fluent API that allows users to construct, validate, and execute workflows seamlessly with minimal overhead.
CompletableFuture—to deliver a straightforward and efficient orchestration solution. No bloated frameworks or configurations are necessary.Here's a brief example illustrating how to define and execute a workflow using AdaptiveFlow:
import io.github.varun51.adaptiveflow.WorkflowBuilder;
import io.github.varun51.adaptiveflow.WorkflowResult;
import io.github.varun51.adaptiveflow.RetryPolicy;
import java.time.Duration;
WorkflowResult result = WorkflowBuilder.builder("etl")
.task("extract", ctx -> fetchRows())
.task("validate", ctx -> validate(ctx.<Rows>result("extract")))
.parallel(
WorkflowBuilder.TaskRef.of("summary", ctx -> summarize(ctx.<Rows>result("extract"))),
WorkflowBuilder.TaskRef.of("archives", ctx -> archive(ctx.<Rows>result("extract")))
)
.task("load", ctx -> load(ctx.<Summary>result("summary"), ctx.<Archive>result("archives")))
.retry(RetryPolicy.exponentialBackoff(4, Duration.ofMillis(100)))
.execute();
if (result.isSuccess()) {
Summary summary = result.<Summary>result("summary");
}
Post 1.0, AdaptiveFlow aims to introduce adaptive scheduling capabilities that are resource-aware, with features that evolve based on live execution patterns.
This Java library is ideal for developers seeking an efficient way to orchestrate complex workflows within Java applications using the latest advancements in the Java ecosystem.
Comments
0Start the conversation
Share the first comment.