Skip to content

Repository files navigation

Build GitHub release

Chainy

Chainy is a small util to help chain, different async requests together and build a final result.

Quick start

Artifact & Repository

Start by adding the jitpack repository to your project with the artifacts you want to use.

repositories {
    mavenCentral()
    mavenLocal()
    maven("https://jitpack.io")
}
dependencies {
    implementation("com.github.einnxk:chainy:1.0.0-SNAPSHOT")
}

Building a Chain

package dev.einnik.chainy.example;

import dev.einnik.chainy.Chain;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

public class Example {

    public CompletableFuture<PlayerProfile> loadProfile() {
        public CompletableFuture<PlayerProfile> fetchPlayerProfile(UUID uuid) {
            return Chain.startWith(0, () -> new PlayerDataState(uuid))
                    .then(1, state -> state.withName(loadName(state.uuid())))
                    .then(2, state -> state.withPlayTime(loadPlayTime(state.uuid())))
                    .thenAsynchronously(3, state -> loadFriendsAsync().thenApply(state::withFriends))
                    .then(4, PlayerDataState::buildProfile)
                    .asynchronously();
        }
    }
}

Build

Chainy uses Gradle to handle dependencies & building.

Requirements:

  • Java 25 JDK or newer
  • Git
  • Gradlew installed

Compiling from source

git clone https://github.com/einnxk/chainy.git
cd Chainy/
./gradlew clean build

License

Chainy is licensed under the Apache 2 license. Please see the LICENSE for more info.

About

A synchron and asynchron java workflow chaining framework

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages