Boru is a pipeline solution

Overview

boru Maven Central Release boru codecov

boru

boru is a pipeline implementation in kotlin with native coroutine support and custom dsl.

Supports chaining pipeline steps with conditions and branches.

Inspired by @oguzhaneren's C# implementation

<dependency>
    <groupId>com.trendyol</groupId>
    <artifactId>boru</artifactId>
    <version>1.0.0</version>
</dependency>

USAGE

Defining Context

Define a context implementing PipelineContext. In this case a simple context that sets and gets a text field

interface PipelineContext {
    val items: Map<Any, Any>
}

class TestDataContext : PipelineContext {
    override val items: MutableMap<Any, Any> = mutableMapOf()

    var intValue: Int = 0

    var text: String?
        get() = items.getOrDefault("Text", null).toString()
        set(value) {
            items["Text"] = value!!
        }
}

Define Pipeline Steps

Implement a pipeline step using TestDataContext

class TestWriterStep(
    private val text: String,
) : PipelineStep<TestDataContext> {

    override suspend fun execute(context: TestDataContext, next: PipelineStepDelegate<TestDataContext>) {
        context.text = text
        next(context)
    }
}

Build Pipeline

fun compose() {
    val pipeline = PipelineBuilder<TestDataContext>()
        .usePipelineStep(TestWriterStep("hello"))
        .build()
    val context = TestDataContext()
}

You can also use lambda functions without defining a pipeline step

fun compose() {
    val pipeline = PipelineBuilder<TestDataContext>()
        .use { context: TestDataContext, next: suspend () -> Unit ->
            context.text = "hello"
            next()
        }
        .build()
    val context = TestDataContext()
}

Or use built-in dsl

fun compose() {
    val pipeline = pipelineBuilder<TestDataContext> {
        use { testDataContext: TestDataContext, next: suspend () -> Unit ->
            context.text = "Hello World"
            next()
        }
    }
}

Conditions and Branching

You can also use conditions when executing steps or branch using map operation

fun compose() {
    val pipeline = pipelineBuilder<TestDataContext> {
        usePipelineStepWhen(TestWriterStep("Hello World")) {
            it.text == "ExecuteStep"
        }
    }
}

Mapping allows you to group multiple steps under one condition.

fun composeMapping() {
    val pipeline = pipelineBuilder<TestDataContext> {
        map({ it.intValue < 3 }) {
            usePipelineStep(TestWriterStep("one"))
            usePipelineStep(TestWriterStep("two"))
        }
        map({ it.intValue == 3 }) {
            usePipelineStep(TestWriterStep("three"))
        }
    }
}

Examples

You can check out other examples

You might also like...
A seed and demo about how to do end-to-end testing of a Dataflow pipeline

dataflow-e2e-demo This is a demo and a seed project to show how you can end-to-end test a Dataflow pipeline. You can find more about by follwing this

A Template for a Github Actions Pipeline for building and publishing Gradle-JVM Applications

github-actions-cd-template-jvm A Template for a Github Actions Pipeline for building and publishing Gradle-JVM Applications It build a executable shad

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.

Check out ObjectBox Check out our new mobile database ObjectBox (GitHub repo). ObjectBox is a superfast object-oriented database with strong relation

a solution that can help developers display pictures in any shape.
a solution that can help developers display pictures in any shape.

android-anyshape With the solution, pictures can be displayed in any shape on Android platform. Effect The left is the UI using normal ImageViews, and

Advanced dialog solution for android
Advanced dialog solution for android

DialogPlus Simple and advanced dialog solution. Uses normal view as dialog Provides expandable option Multiple positioning Built-in options for easy i

A solution for streaming H.264, H.263, AMR, AAC using RTP on Android

Introduction What it does libstreaming is an API that allows you, with only a few lines of code, to stream the camera and/or microphone of an android

Compact and easy to use, 'all-in-one' android network solution
Compact and easy to use, 'all-in-one' android network solution

Deprecated Unfortunately due to many reasons including maintenance cost, this library is deprecated. I recommend to use Retrofit/OkHttp instead. Curre

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk. Getting started Add t

xLua is a lua programming solution for  C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.
xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.

(English Documents Available) C#下Lua编程支持 xLua为Unity、 .Net、 Mono等C#环境增加Lua脚本编程的能力,借助xLua,这些Lua代码可以方便的和C#相互调用。 xLua的突破 xLua在功能、性能、易用性都有不少突破,这几方面分别最具代表性的

A RecyclerView solution, support addHeaderView、addFooterView
A RecyclerView solution, support addHeaderView、addFooterView

HeaderAndFooterRecyclerView Introduction HeaderAndFooterRecyclerView is a RecyclerView solution that supports addHeaderView, addFooterView to a Recycl

A Popover Controller for Android Tablets. It's an easy solution to simulate an iOS UIPopoverController
A Popover Controller for Android Tablets. It's an easy solution to simulate an iOS UIPopoverController

PopoverView A Popover Controller for Android Tablets. It's an easy solution to simulate an iOS UIPopoverController Base example 9patch image comes fro

Mobile app to Show Movies From TMDB API [Qhala Interview Solution], for the Android Engineer Role
Mobile app to Show Movies From TMDB API [Qhala Interview Solution], for the Android Engineer Role

Qhala Interview 🎥 📺 This is an Interview Tech challenge by Qhala I used TMDB API to solve this challenge. Screenshots Movies Movie Detail Prerequisi

Native solution for common React Native problem of focused views being covered by soft input view.

react-native-avoid-softinput Native solution for common React Native problem of focused views being covered by soft input view. It is solved by listen

pokestack is an all-in-one solution for mobile voice interfaces on Android.
pokestack is an all-in-one solution for mobile voice interfaces on Android.

Extensible Android mobile voice framework: wakeword, ASR, NLU, and TTS. Easily add voice to any Android app!

Show weather data for the current location [Apollo Agriculture Interview Solution], for the Senior Android Engineer Role
Show weather data for the current location [Apollo Agriculture Interview Solution], for the Senior Android Engineer Role

Apollo Agriculture Android Take Home Assignment Writing Apollo Agriculture App using Android Architecture Components, in 100% Kotlin, using Android Je

 Math World is an Android Application specialized in mathematics, where the application includes some sections related to arithmetic, unit conversion, scientific math laws and constants, as well as some mathematical questions that need some intelligence to reach the solution.
Math World is an Android Application specialized in mathematics, where the application includes some sections related to arithmetic, unit conversion, scientific math laws and constants, as well as some mathematical questions that need some intelligence to reach the solution.

Math World is an Android Application specialized in mathematics, where the application includes some sections related to arithmetic, unit conversion, scientific math laws and constants, as well as some mathematical questions that need some intelligence to reach the solution.

From 8-10 October 2021 there was VTB MORE tech 3.0, where the DUCK team presented their solution.
From 8-10 October 2021 there was VTB MORE tech 3.0, where the DUCK team presented their solution.

InvestmentGuideVTB Ссылка на репозиторий с бэкендом приложения: https://github.com/disarrik/vtbBackend Процесс сегментация происходит в отдельном окне

COVID-19 Check-in solution for store using a safe number based on MVVM model.
COVID-19 Check-in solution for store using a safe number based on MVVM model.

wave-in-listener English version : README_EN.md wave-in-listener 는 매장에 방문한 고객의 개인안심번호를 음파통신을 이용해 수신할 수 있는 앱입니다. 이 앱은 wave-in-speaker 앱과 함께 사용됩니다. wave

COVID-19 Check-in solution using a safe number based on MVVM model.
COVID-19 Check-in solution using a safe number based on MVVM model.

wave-in-speaker wave-in-speaker는 방문하는 공간에 전자출입명부를 쉽게 남기도록 도와주는 앱이며 특히 코로나 바이러스 감염증(COVID-19) 기간동안 효과적으로 사용가능합니다. 이 앱을 사용하면 QR코드 대신 음파 통신으로 체크인할 수 있습니다

Owner
Trendyol Open Source
Trendyol Open Source
A seed and demo about how to do end-to-end testing of a Dataflow pipeline

dataflow-e2e-demo This is a demo and a seed project to show how you can end-to-end test a Dataflow pipeline. You can find more about by follwing this

null 0 Dec 18, 2021
From 8-10 October 2021 there was VTB MORE tech 3.0, where the DUCK team presented their solution.

InvestmentGuideVTB Ссылка на репозиторий с бэкендом приложения: https://github.com/disarrik/vtbBackend Процесс сегментация происходит в отдельном окне

Denis 1 Nov 8, 2021
Solution for task 5 on Spring Boot https://t.me/try2py/197

IouRestService (Spring Boot Application) Решение задачи 5 https://t.me/try2py/197 Условие задачи: Четверо соседей по комнате имеют привычку занимать д

Fomin Sergei 1 Nov 22, 2021
BOJ PS - Solution of BOJ Problem

BOJ_1009 분산처리 https://www.acmicpc.net/problem/1009 10개의 컴퓨터 그리고 N개의 데이터가 있을 경우 1

hyungmin 0 Jan 5, 2022
ComposeSwipeToReveal - A compose solution for adding swipe to reveal to a list

ComposeSwipeToReveal A compose solution for adding swipe to reveal to a list. A

null 1 Jan 9, 2022
Solution code for Android Kotlin Fundamentals Codelab 8.1 Getting data from the internet

MarsRealEstateNetwork - Solution Code Solution code for Android Kotlin Fundamentals Codelab 8.1 Getting data from the internet Introduction MarsRealEs

DavidHieselmayr 1 Apr 7, 2022
This project aims to provide a solution for finding the right product for a given EAN (European Article Number)

This project aims to provide a solution for finding the right product for a given EAN (European Article Number)

MJ 1 Apr 18, 2022
Auto-pipeline: a source code generator, it will generate your component's pipeline

auto-pipeline ?? auto-pipeline is a source code generator, it will generate your

Zava 106 Dec 20, 2022
Bamboo pipeline Specification by example

#Bamboo specification by example in Kotlin Official documentation Bamboo Java Spec documentation Based on the documentation - there are 2 possibilitie

Roman Marinsky 0 Nov 3, 2021
Gradle plugin to manage tests which should only run nightly and not every time a CI/CD pipeline builds.

NightlyTestsPlugin Gradle Plugin to configure which (j)Unit tests should only be run nightly and not everytime a CI/CD pipeline is triggered. Usage To

VISUS Health IT GmbH 0 Dec 7, 2021