Skip to content
Scala DSL and other Scala Code for Simple Sagas
Scala Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Simple Sagas - Scala

Build Status

This repo has been formed by splitting the Scala code from the main Simple Sagas repo.

Saga DSL

A simple DSL is provided to simplify creating sagas, loosely based on the Akka Streams Graph DSL

  1. Create a builder:

    import io.simplesource.saga.scala.dsl._
    val builder = SagaBuilder[A]()
  2. Add some actions:

    val a = builder.addAction(...)
    val b = builder.addAction(...)
    val c = builder.addAction(...)
    val d = builder.addAction(...)
    val e = builder.addAction(...)
  3. Defined dependencies between actions:


    Execute a, then b, then c:

    a ~> b ~> c

    Execute a, then b, c and d in parallel, then e:

    a ~> b ~> e
    a ~> c ~> e
    a ~> d ~> e

    This can also be expressed as:

    a ~> inParallel(b, c, d) ~> e
    a ~> List(b, c, d).inParallel ~> e

    Execute a, then b, c and d in series, then e. The following are equivalent:

    a ~> b ~> c ~> d ~> e
    inSeries(a, b, c) ~> d ~> e
    inSeries(a, b, c, d, e)
    a ~> inSeries(b, c, d) ~> e
    a ~> List(b, c, d).inSeries ~> e

    This is useful when we have a sequence of actions of length only known at runtime.

    Note that the ~> operator is associative, so (a ~> b) ~> c is equivalent to a ~> (b ~> c).

  4. Build the immutable sagas graph:

    val eitherSaga: Either[SagaError, Saga[A]] =
You can’t perform that action at this time.