-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add metered #1294
Add metered #1294
Conversation
/** | ||
* Like [[iterate]], but emits elements with the fixed rate of `d`. | ||
*/ | ||
def iterateEvery[F[_], A](d: FiniteDuration)(start: A)(f: A => A)(implicit timer: Timer[F]): Stream[F, A] = |
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.
Not sure about the name here. I think this is related to scheduling and perhaps we have somehow express this. Something like iterateAtRate or similar.
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.
@pchlupacek I named it consistently with awake
family (awakeEvery). But iterateAtRate
also fits.
I'm fine with both.
Actually, pronouncing iterateAtRate
feels a bit awkward :)
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.
I am not expert on the naming these mouthful operators. Lets see what @SystemFw @mpilquist thinks about this.
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.
My whole idea is that awake
sort of implies the scheduling, where iterate
does not plus, we already use iterate for bunch of scheduling unrelated methods.
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.
iterateEvery
is fine as a name, it's consistent with awakeEvery
. I'm slightly more doubtful that this op warrants inclusion (you can add an *Every
to every op in the lib), but not really opposed to it either, whatever you guys prefer
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.
Also, as side note we could make perhpas
metered
to be more effective than zipping, by just inserting it at every value emitted.... likethis.evalMap { a => Timer.sleep(d) as a }
Doesn't this change the semantics from fixedRate
to fixedDelay
?
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.
this sense smthing like atMaxRateOf could be more precise
That's not the case, if the other stream is slower it will be slower.
ike this.evalMap { a => Timer.sleep(d) as a }
These semantics are different, that's fixedDelay
, not fixedRate
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.
yeah it does. :-)
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.
if the other stream is slower it will be slower.
I might be wrong, but I think that's what maxRate
implies - if this
is too fast, the rate is limited, but if it's slow, the rate is slow as well.
metered
is more concise though, I'll go with it.
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.
I might be wrong, but I think that's what maxRate implies
nah, you're right, the ratio there got me :P
I've spent like 15 min on the scala doc, but still feel it can be worded better :) |
No description provided.