samedi 15 avril 2023

Is Chain of Responsibilities suitable for creating DAG like pipelines?

I understand that the CoR pattern is used when we have a sequence of tasks that need to be carried out, each takes the previous output as input and produces some new output.

Now I would like to see if I can apply this pattern to create non-linear pipelines. I have something like this in Kotlin:

interface Handler<I, O> {
    fun handle(input: I): Result<*>
}

How can I make it so that I can implement something like the following with concurrent execution path?

Peel mangos (Mango -> PeeledMango)
|
Dice mangos (PeeledMango -> DicedMango)
|    
|
|    Peel bananas (Banana -> PeeledBanana)
|    |
|    Dice bananas (PeeledBanana -> DicedBanana)
|  /
|/
|
Blend (DicedMango, DicedBanana, Yogurt, Milk -> MangoBananaSmoothie)

Aucun commentaire:

Enregistrer un commentaire