Skip to content

Operator: throttleWithTimeout - #366

Closed
benjchristensen wants to merge 2 commits into
ReactiveX:masterfrom
benjchristensen:throttleWithTimeout
Closed

Operator: throttleWithTimeout#366
benjchristensen wants to merge 2 commits into
ReactiveX:masterfrom
benjchristensen:throttleWithTimeout

Conversation

@benjchristensen

Copy link
Copy Markdown
Member

Another take on throttle … I believe this matches Rx.Net behavior.

This will wait until timeout value has passed without any further values before emitting the received value.

Another take on `throttle` … I believe this matches Rx.Net behavior.
This will wait until timeout value has passed without any further values before emitting the received value.
@benjchristensen

Copy link
Copy Markdown
MemberAuthor

This example will throttle by waiting until timeout value has passed without any other onNext calls before emitting. If anything else is emitted it will throw away the previous value and restart the timer.

This will not emit anything if events keep firing shorter than the timeout.

PublishSubject<Integer> o = PublishSubject.create();
o.throttleWithTimeout(500, TimeUnit.MILLISECONDS, s).subscribe(observer);
// send events with simulated time incrementss.advanceTimeTo(0, TimeUnit.MILLISECONDS);
o.onNext(1); // skipo.onNext(2); // delivers.advanceTimeTo(501, TimeUnit.MILLISECONDS);
o.onNext(3); // skips.advanceTimeTo(600, TimeUnit.MILLISECONDS);
o.onNext(4); // skips.advanceTimeTo(700, TimeUnit.MILLISECONDS);
o.onNext(5); // skipo.onNext(6); // deliver at 1300 after 500ms has passed since onNext(5)s.advanceTimeTo(1300, TimeUnit.MILLISECONDS);
o.onNext(7); // delivers.advanceTimeTo(1800, TimeUnit.MILLISECONDS);
o.onCompleted();

Compare with #365

@benjchristensenbenjchristensen mentioned this pull request Sep 10, 2013
@benjchristensen

Copy link
Copy Markdown
MemberAuthor

Please review this behavior and let me know if it is accurate and if the name is explanatory.

@cloudbees-pull-request-builder

Copy link
Copy Markdown

RxJava-pull-requests #259 SUCCESS
This pull request looks good

@samuelgruetter

Copy link
Copy Markdown
Contributor

throttleLast and throttleWithTimeout both have the same javadoc, that's confusing...

@samuelgruetter

Copy link
Copy Markdown
Contributor

that was fast :D

@benjchristensen

Copy link
Copy Markdown
MemberAuthor

Javadoc:

Throttles by dropping all values that are followed by newer values before the timeout value expires. The timer reset on each onNext call.
NOTE: If the timeout is set higher than the rate of traffic then this will drop all data.

@benjchristensen

Copy link
Copy Markdown
MemberAuthor

I have submitted 3 separate pull requests with different variants of throttle. I would appreciate feedback on them:

  • is the name and javadoc descriptive?
  • does the throttling strategy make sense?

Variants are:

@samuelgruetter

Copy link
Copy Markdown
Contributor
  • throttleWithTimeout: the really interesting one, not easily implemented using other operators, corresponds to the C# version
  • throttleLast: easily obtained combining window, flatMap, and takeLast
  • throttleFirst: easily obtained combining window, flatMap, and takeFirst

Is this correct?

@benjchristensen

Copy link
Copy Markdown
MemberAuthor

Yes.

jihoonson pushed a commit to jihoonson/RxJava that referenced this pull request Mar 6, 2020
* add Bulkhead annotation and aspect
* fixed failing tests by separating retry backends.
* extracted duplicated code to AnnotationExtractor
* add Bulkhead annotation and aspect
* fixed failing tests by separating retry backends.
* extracted duplicated code to AnnotationExtractor
* extracted duplicated code to AnnotationExtractor
* added @AutoConfigureBefore and fixed wrong parameter names.
* removed bulkhead health indicator
* added dirtiesContext
* fixed failing tests.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@benjchristensen@cloudbees-pull-request-builder@samuelgruetter