Skip to content

Instantly share code, notes, and snippets.

@huntc huntc/server.scala
Last active Dec 12, 2017

What would you like to do?
A complete server using Akka streams that reads some source, batches its data and then publishes. If the data cannot be published then it backs off with a best-effort of sending that data again.
val (recycleQueue, recycleSource) =
.queue[SoilStateReading](100, OverflowStrategy.dropTail)
StreamConverters.fromInputStream(() => this.getClass.getClassLoader.getResourceAsStream("sensors.log"))
.batch(100, e => List(e))((a, e) => e +: a)
.via(RestartFlow.withBackoff(1.second, 3.seconds, 0.2) { () =>
.mapAsync(1) { readings =>
.recover {
case e: IllegalStateException =>
throw e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.