Hi,

On Fri, Jun 5, 2015 at 7:53 PM, Владимир Морозов <greenhos...@gmail.com>
wrote:

> Yes, I know about mapAsync, but my problem with Source. A want to use
> single stream for processing some group of events
>

I am not sure if I understand your question properly, but if you want to
run the stream *once* and then reuse the stream for all the requests, then
you can try to create an ActorPublisher as your Source, then run the stream
outside of the Http handler logic. You can then use "ask" on that actor in
the Http route.

-Endre


>
> пятница, 5 июня 2015 г., 20:29:16 UTC+3 пользователь Paul Kinsky написал:
>
>> Use mapAsync: `def mapAsync[T](parallelism: Int)(f: (Out) ⇒ Future[T]):
>> Repr[T, Mat]`.
>>
>> On Friday, June 5, 2015 at 9:23:24 AM UTC-7, Владимир Морозов wrote:
>>>
>>> Hi all,
>>>
>>> I have some simple application based on akka streams and http:
>>>
>>> My Flow items:
>>>
>>> val resultSink = Sink.head[String]
>>>
>>> val fl0 = Flow[String].map(_.toInt)
>>> val fl2 = Flow[Int].map{
>>>     case value =>
>>>         Thread.sleep(10000)
>>>         value.toString
>>> }
>>> val fl3 = Flow[String].mapAsync(1)(callMe)
>>>
>>>
>>> Part of my akka-http route:
>>>
>>> val route = get {
>>>     path("test") {
>>>         path("register") {
>>>             parameter('username) { case username: Username =>
>>>                 
>>> Source.single(username).via(fl0).via(fl2).via(fl3).runWith(resultSink):
>>> Future[String]
>>>         }
>>>     }
>>> }
>>>
>>> I want to use one flow : Source.single(username).
>>> via(fl0).via(fl2).via(fl3).runWith(resultSink) for processing all
>>> requests. I want this for use streams back-pressure. But I can't figure out
>>> how create Source that can accept values like call def proccess(username:
>>> String): Future[String] but with back-pressure, because, for example, a
>>> want long-call DB in fl2 step, and DB can't accept more than 1 request
>>> per time (only for example)
>>>
>>> With best regards, Vladimir.
>>>
>>>  --
> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to