Parallel Execution
etl4s has an elegant shorthand for grouping and parallelizing operations that share the same input type:
import etl4s._
/* Simulate slow IO operations (e.g: DB calls, API requests) */
val e1 = Extract { Thread.sleep(100); 42 }
val e2 = Extract { Thread.sleep(100); "hello" }
val e3 = Extract { Thread.sleep(100); true }
Sequential run of e1, e2, and e3 (~300ms total)
Parallel run of e1, e2, e3 on their own JVM threads with Scala Futures (~100ms total, same result, 3X faster)
import scala.concurrent.ExecutionContext.Implicits.global
val parallel: Extract[Unit, ((Int, String), Boolean)] =
e1 &> e2 &> e3
Full example of a parallel pipeline: