-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timed Pull #2062
Merged
Merged
Timed Pull #2062
Changes from 66 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
cae950a
Gather ideas for generalised groupWithin
SystemFw c171a75
Add key implementation notes for TimedPull
SystemFw d2dcf76
Sketch out TimedPull without explicit queues
SystemFw a9b2632
Add roughly working prototype of groupWithin based on TimedPull
SystemFw 8cc3109
Cleanup implementation of TimedPull
SystemFw 87cedfd
Make Timeout existential in TimedPull
SystemFw 15ded9b
Remove stale code
SystemFw 6cfb7a4
Add TODOs
SystemFw 9ac3843
Start the initial timer in groupWithin with TimedPull
SystemFw 9936e76
Add test for equivalence between groupWithin and chunkN
SystemFw 2c99bbd
Sketch strategy for testing stale timeouts
SystemFw 904fd93
Identity groupWithin corner case on first chunk
SystemFw 5cfa6cf
Detail groupWithin bug
SystemFw e6de3b7
Add test case for chunk manipulation in groupWithin
SystemFw 3ef1dca
Fix compile error in dotty
SystemFw 7b20b07
Better logic to filter stale timeouts
SystemFw b420b74
Clean up logic for emitting non empty chunks only
SystemFw eb3449d
Prototype groupWithin semantics for timeout with empty accumulator
SystemFw 365fc6d
Remove stale code
SystemFw 1ad6e8e
Work towards reproducing the timeout reset bug in groupWithin
SystemFw f718fa6
Add groupWithin timeout reset test
SystemFw 6a7ff93
Remove stale code
SystemFw 3a45fcb
Stub TimedPullSuite
SystemFw 41b8bc3
Add TimedPull testing ideas
SystemFw 0e7d20c
Move TimedPull within ToPull syntax
SystemFw 16ec2ce
Implement groupWithin with TimedPull
SystemFw 302ab13
Do not reset timeout in groupWithin if nothing is emitted
SystemFw 82ad529
Fix ambiguous implicit in Scala 2
SystemFw ea58068
Introduce TimedPull.apply to avoid AnyVal restrictions
SystemFw baf4494
Do not hardcode return type in TimedPull
SystemFw d7d8dd8
Introduce time resetting helper in groupWithin
SystemFw 419fb21
Split hasTimedOut into its own case
SystemFw c1ac498
Never emit empty chunks in groupWithin
SystemFw f1616fb
Add test for conditions check in groupWithin
SystemFw c15ad19
Empty chunks cannot be emitted
SystemFw ac950f6
Cosmetics
SystemFw 08013cf
Add simple test for TimedPull
SystemFw 9d19924
More happy path tests for TimedPull
SystemFw c53aada
Add test for simple timeout
SystemFw 81046b1
Identity problem with Signal and unNone
SystemFw d7c90f8
Sketch solution to initial busy wait in TimedPull
SystemFw 2da164b
Do not rely on unNone in TimedPull timeout handling
SystemFw 7237f6b
Fix busy waiting when spinning up TimedPulls
SystemFw c7a9584
Cosmetics
SystemFw ed4627f
Use ticked in test previously affected by busy waiting
SystemFw edc9958
reduce test runtime
SystemFw 54d0649
Add time annotations for 2.13
SystemFw 9c1ab1e
Add timeout reset test
SystemFw bf5124c
Remove dead code
SystemFw 0dc0748
Attempt test for timeout in flight reset
SystemFw cf35e36
Fix numeric widening
SystemFw eda9939
Fix timeout reset test - TimedPull is strongly pull-based
SystemFw 2d47cbc
Cosmetics
SystemFw ee60a16
More timeout tests
SystemFw bbab038
Test for stale timeouts
SystemFw f1c5cb3
Specify the ability to shorten timeouts
SystemFw f0b89dc
Redesign timeouts in TimedPull to allow shortening of timeouts
SystemFw 7044f85
Eliminate custom Timeout class in TimedPull
SystemFw 0d5dd13
Move definition of TimedPull into timed method
SystemFw f44178d
Remove standalone TimedPull
SystemFw c95e4ef
Rename TimedPull.startTimer to timeout
SystemFw ae13e33
Refactor TimedPullSuite
SystemFw b21ad2a
Add ability to cancel a timeout without having to start another one
SystemFw e7e93a8
Add TimedPull example
SystemFw 4fa9e24
Add scaladoc for pull.timed
SystemFw c00946a
Add scaladoc for TimedPull
SystemFw 70bcf9b
TimedPull --> Pull.Timed
SystemFw ab6bf2b
Fix scaladoc links
SystemFw 2eab6b2
Complete scaladoc for Pull.Timed
SystemFw 8ae0947
Revamp scaladoc for groupWithin
SystemFw b3c8203
Remove playground
SystemFw 92c3767
Formatting
SystemFw 5249926
Merge branch 'develop' into timed-pull
SystemFw 7802b8b
Formatting
SystemFw 099a13e
Fix exhaustivity warning
SystemFw e59a02c
Ignore the secondary groupWithin leak test
SystemFw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2013 Functional Streams for Scala | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
* the Software without restriction, including without limitation the rights to | ||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software, and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package fs2 | ||
|
||
|
||
object ex { | ||
|
||
import cats.effect.IO | ||
import cats.effect.unsafe.implicits.global | ||
import scala.concurrent.duration._ | ||
|
||
val emitThenWait = Stream("elem") ++ Stream.sleep_[IO](200.millis) | ||
val s = emitThenWait.repeat.take(3) | ||
|
||
def a = s.pull | ||
.timed { timedPull => | ||
def go(timedPull: Stream.TimedPull[IO, String]): Pull[IO, String, Unit] = | ||
timedPull.timeout(150.millis) >> // starts a timeout timer, resets the previous one | ||
timedPull.uncons.flatMap { | ||
case Some((Right(elems), next)) => Pull.output(elems) >> go(next) | ||
case Some((Left(_), next)) => Pull.output1("late!") >> go(next) | ||
case None => Pull.done | ||
} | ||
|
||
go(timedPull) | ||
}.stream.compile.toVector.unsafeRunSync() | ||
//val res0: Vector[String] = Vector(elem, late!, elem, late!, elem) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on defining this as
Pull.Timed
instead ofStream.TimedPull
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh interesting. It is closer to
ToPull
in spirit, but I do likePull.Timed
and it's probably more discoverable, so if you're definitely 👍 onPull.Timed
, I'll move it there :)