Thanks for the ideas (tick, delay), that's much better than Thread.sleep 
indeed!

I didn't want to test groupedWithin initially. I wanted to implement my own 
groupedWithin with a slighly different requirement - an element timer (much 
shorter) and a group timer such that:
- each new incoming element would reset the element timer.
- when either the element or group timer expires, the group is closed

Bruno

On Monday, January 11, 2016 at 1:11:34 PM UTC+1, rkuhn wrote:
>
> Hi Bruno,
>
> why would you want to test groupedWithin? If you have additional test 
> cases then please add them to FlowGroupedWithinSpec, otherwise it is 
> reasonable to assume that it does what it promises :-)
>
> Regards,
>
> Roland
>
> 11 jan 2016 kl. 12:22 skrev Bruno Bieth <bie...@gmail.com <javascript:>>:
>
> Yeah :) but I couldn't figure a quicker way to test groupedWithin.
>
> On Monday, January 11, 2016 at 12:06:53 PM UTC+1, √ wrote:
>>
>> And of course "Thread.sleep()" is evil™ also always applies.
>>
>> On Mon, Jan 11, 2016 at 11:47 AM, Bruno Bieth <bie...@gmail.com> wrote:
>>
>>> Thanks,
>>>
>>> @drewhk <https://github.com/drewhk> told me this as well and it works! 
>>> I forgot that akka-stream 2.0 introduced fusing...
>>>
>>> Regards,
>>> Bruno
>>>
>>>
>>> On Monday, January 11, 2016 at 10:36:28 AM UTC+1, rkuhn wrote:
>>>>
>>>> Hi Bruno,
>>>>
>>>> it works with fuzzing because the interpreter will only process one 
>>>> step before looking into its Actor mailbox—but what actually breaks things 
>>>> is your usage of Thread.sleep. If you want to block, you’ll typically want 
>>>> to do so behind an Attributes.asyncBoundary.
>>>>
>>>> Regards,
>>>>
>>>> Roland
>>>>
>>>> 11 jan 2016 kl. 10:26 skrev Bruno Bieth <bie...@gmail.com>:
>>>>
>>>> Turns out it works with fuzzing (explaining why it passes the test 
>>>> suite).
>>>> I've submitted an issue: https://github.com/akka/akka/issues/19394
>>>>
>>>> On Monday, January 11, 2016 at 8:45:19 AM UTC+1, Bruno Bieth wrote:
>>>>>
>>>>> I can't tell if I'm doing something wrong in this code:
>>>>>
>>>>> implicit val as = ActorSystem()
>>>>> implicit val mat = ActorMaterializer()
>>>>>
>>>>> val future = Source.fromIterator(() => new Iterator[Int] {
>>>>>   var i = 0
>>>>>   override def hasNext: Boolean = true
>>>>>   override def next(): Int = {
>>>>>     println(s"Waiting $i seconds")
>>>>>
>>>>>     scala.concurrent.blocking {
>>>>>
>>>>> Thread.sleep(i * 1000)
>>>>>
>>>>>     }
>>>>>     i = i + 1
>>>>>     i
>>>>>   }
>>>>> }).groupedWithin(20, 2.seconds).runForeach(println)
>>>>>
>>>>> Await.ready(future, 10.seconds)
>>>>>
>>>>>
>>>>> It seems to me that at least something should be printed. But the 
>>>>> output invariably is:
>>>>>
>>>>> Waiting 0 seconds
>>>>> Waiting 1 seconds
>>>>> Waiting 2 seconds
>>>>> Waiting 3 seconds
>>>>> Waiting 4 seconds
>>>>> Waiting 5 seconds
>>>>>
>>>>> java.util.concurrent.TimeoutException: Futures timed out after [10000 
>>>>> milliseconds]
>>>>>
>>>>> I tried to follow the code of GroupedWithin and it seems that the 
>>>>> timer works as expected but then when the AsyncCall gets called nothing 
>>>>> happens (from `GraphStage`):
>>>>>
>>>>> interpreter.onAsyncInput(GraphStageLogic.this, event, 
>>>>> handler.asInstanceOf[Any ⇒ Unit])
>>>>>
>>>>>
>>>>> Bruno
>>>>>
>>>>
>>>> -- 
>>>> >>>>>>>>>> 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+...@googlegroups.com.
>>>> To post to this group, send email to akka...@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+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Cheers,
>> √
>>
>
> -- 
> >>>>>>>>>> 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+...@googlegroups.com <javascript:>.
> To post to this group, send email to akka...@googlegroups.com 
> <javascript:>.
> 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.

Reply via email to