Thanks so much Roland. That makes sense. As a bonus, your comment about
addAttributes vs withAttributes might explain why I wasn't seeing .log
output :)

On Thu, Mar 3, 2016 at 12:04 AM, Roland Kuhn <goo...@rkuhn.info> wrote:

> Hi Richard,
>
> 3 mar 2016 kl. 00:24 skrev Richard Rodseth <rrods...@gmail.com>:
>
> This whole area of async boundaries in akka streams is still very
> confusing to me. I don't know what to suggest in terms of documentation,
> other than numerous examples of code, with corresponding diagrams showing
> the resultant boundaries and actor instances after materialization.
>
> As an example, I have a Sink which I use for console output. I'm sure you
> will tell me to use logging, but I didn't wish to deal with log levels and
> formatting for what is the real UI of the tool.
>
> So I have a  Sink:
>
>   def printSinkWithLabel[T](extractor: T => String): Sink[T, 
> Future[akka.Done]]
> = Sink.foreach[T] { e => println(extractor(e)) }
>
>     .withAttributes(ActorAttributes.dispatcher(
> "dispatcher-for-blocking-console"))
>
>     .async // Should I have this?
>
> and a flow which uses it in an alsoTo()
>
>   def progress[T](extractor: T => String) = {
>
>     val flow = Flow[T]
>
>     .alsoTo(Sinks.printSinkWithLabel(extractor) )
>
>     .withAttributes(ActorAttributes.dispatcher(
> "dispatcher-for-blocking-console"))
>
>     flow
>
>   }
>
> WIth these I can do a via(progress(extractor)) as needed.
>
> Do I need the dispatcher attributes in both places?
>
>
> No, running the Sink on that dispatcher is sufficient, you don’t need (or
> want) to run the alsoTo on that dispatcher as well.
>
> Which is more appropriate?
>
>
> Running alsoTo on a different dispatcher slows down the “fast path” of
> your data through the progress indicator, so I wouldn’t recommend that.
>
> Is the .async on the Sink necessary/appropriate?
>
>
> Strictly speaking the .async is unnecessary if you know that the
> surrounding combinators (.alsoTo in this case) run on a different
> dispatcher, but I think it clearly spells out the intent to add this
> attribute explicitly.
>
> Does it make any difference if it's before or after the withAttributes?
>
>
> Yes, and that is something we should definitely put into the ScalaDoc as
> well as reference docs: .withAttributes replaces the attributes that were
> already on the Sink.foreach (which is just a .named("foreachSink") here,
> but it would include the .async if the order is swapped). If you use
> .addAttributes instead then the order does not matter.
>
> Regards,
>
> Roland
>
> Thanks in advance.
>
> --
> >>>>>>>>>> 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 https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> *Dr. Roland Kuhn*
> *Akka Tech Lead*
> Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
> twitter: @rolandkuhn
> <http://twitter.com/#!/rolandkuhn>
>
> --
> >>>>>>>>>> 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 https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to