portals-project / portals

Portals is a framework for stateful serverless apps, unifying dataflow streaming with actors
https://www.portals-project.org/
Apache License 2.0
19 stars 2 forks source link

Join and Split method for the FlowBuilder #235

Open jspenger opened 1 year ago

jspenger commented 1 year ago

The FlowBuilder is currently missing a method for joining two flows and splitting a flow.

The split method could have a signature, implemented somewhat like this:

def split[CCU](p1: PartialFunction[CU, Boolean], p2: PartialFunction[CU, Boolean]): FlowBuilder[T, U, CU, CCU =
  (this.filter(x => p1.lift(x).getOrElse(false)), this.filter(x =>p2.lift(x).getOrElse(false))

The join should have a signature like this, which joins the two flows on the key of the flows (note that the key should be set in a separate call to the flow builder by the user):

def join(other: FlowBuilder[T, U, _, CU): FlowBuilder[T, U, CU, CU] =
  ???