Skip to content

Instantly share code, notes, and snippets.

@stanislav-chetvertkov
Created April 27, 2018 11:26
Show Gist options
  • Save stanislav-chetvertkov/4b27e33295a1024a2eebb8ea26b24288 to your computer and use it in GitHub Desktop.
Save stanislav-chetvertkov/4b27e33295a1024a2eebb8ea26b24288 to your computer and use it in GitHub Desktop.
delayedFlow akka streams
object TestRunner {
def delayedFlow[T](delay: FiniteDuration)(implicit scheduler: Scheduler, ec: ExecutionContext): Flow[T, T, _] = {
Flow[T].mapAsyncUnordered(Int.MaxValue) { out =>
val promise = Promise[T]
scheduler.scheduleOnce(delay)(promise.success(out))
promise.future
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment