Hi Devin,
It might even be possible to do that using the flow api combinators,
something like this:
implicit val system = ActorSystem()
implicit val mat = ActorMaterializer()
def fetchFromDatabase(position: Int): Vector[Int] = (position to
(position + 99)).toVector
val periodicFetch: Source[Int, Cancellable] =
Source.tick(0.seconds, 3.seconds, NotUsed)
.statefulMapConcat[Int] { () =>
var lastJob = 0
{ (notUsed) =>
// remember to run stage on separate dispatcher if call is blocking
val rows = fetchFromDatabase(lastJob)
lastJob += 100
rows
}
}
periodicFetch.runWith(Sink.foreach(println))
If you still need more control I'd recommend you to do this using a
GraphStage instead, I think that API is much easier to understand and get
right than the ActorPublisher API, you can find docs and samples here:
http://doc.akka.io/docs/akka/2.4.6/scala/stream/stream-customize.html
--
Johan
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.