A pretty common thing I've to do is to call a (non-blocking, brief) 
callback in the event of an overflow. Usually to send a quick message to 
the logger.

Here's how I normally solve the problem:

  val (input, completed) = Source.actorRef[Int](0, 
OverflowStrategy.dropNew).
    conflate { (prior, overflown) =>
      println(s"dropping overflown ${overflown}")
      prior
    }.
    buffer(10, OverflowStrategy.backpressure).
    async.
    toMat(Sink.foreach { n =>
      println(n)
      Thread.sleep(100)
    })(Keep.both).
    run

  (1 to 50).foreach { n =>
    input ! n
    println(s"sent ${n}")
    Thread.sleep(10)
  }


(full source here 
<https://gist.github.com/timcharper/74e1182badd8458d723bca4c8641280f>)

But this is rather verbose. Is there a more concise way to have support 
behavior?

Another problem with this approach is that I'm creating two async 
boundaries being created (after the actorRef, and then after the conflate); 
that's less efficient than I'd prefer.

Is the best way to do this is to create a custom ActorSubscriber ?

Tim

-- 
>>>>>>>>>>      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