Last active
January 10, 2017 14:03
-
-
Save joost-de-vries/ec81d53d082a148d54ef8bc5ef599bd2 to your computer and use it in GitHub Desktop.
Create a Reactive Streams Publisher from an actor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def scheduledPublisher(buffer: Int, initialDelay: FiniteDuration, interval: FiniteDuration)( | |
| implicit actorSystem: ActorSystem): Publisher[Unit] = { | |
| val actorSource = Source.actorRef[Unit](50, OverflowStrategy.fail) | |
| val (actorRef, publisher) = actorSource.toMat(Sink.asPublisher(fanout = false))(Keep.both).run() | |
| actorSystem.scheduler.schedule(initialDelay, interval, actorRef, ()) | |
| publisher | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment