Skip to content
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

Single.concat(Publisher) defer subscribe to Publisher until requested #1643

Merged
merged 11 commits into from
Jul 2, 2021

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Jun 25, 2021

Motivation:

Current version of Single.concat(Publisher) subscribes to the next
Publisher as soon as the Single completes. If the passed Publisher
does not support multiple subscribes, users can not apply retries if the
further processing of the single result fails.

Modifications:

  • Add Single.concat(Publisher, boolean) overload that tells if we
    need to subscribe to the next Publisher asap or defer subscribe until
    more items are requested;
  • Implement another ConcatDeferNextSubscriber variant that defers
    subscribe to the next publisher, share common code in
    AbstractConcatSubscriber;
  • Enhance tests for new operator variant;

Result:

If processing of the first item failed and no more items were requested,
it's safe to apply retry operator even with a Publisher that do not
support re-subscribe.

Motivation:

`TestSubscription#requestedEquals` depends on the passed `value` and if
`value == 0` it does not check the current cumulative value of requested
elements, it only checks if `request(long)` was ever invoked or not.

Modifications:

- Fix validation in `TestSubscription#requestedEquals`;
- Adjust existing tests to account for new behavior;

Result:

`TestSubscription#requestedEquals(0)` validates that `request(long)` was
invoked and the current cumulative value if equal to `0`.
…sted

Motivation:

Current version of `Single.concat(Publisher)` subscribes to the next
`Publisher` as soon as the `Single` completes. If the passed `Publisher`
does not support multiple subscribes, users can not apply retries if the
further processing of the single result fails.

Modifications:

- Add `Single.concat(Publisher, boolean)` overload that tells if we
need to subscribe to the next `Publisher` asap or defer subscribe until
more items are requested;
- Implement another `ConcatDeferNextSubscriber` varian that defers
subscribe to the next publisher, share common code in
`AbstractConcatSubscriber`;
- Enhance tests for new operator variant;

Result:

If processing of the first item failed and no more items were requested,
it's safe to apply retry operator even with a `Publisher` that do not
support re-subscribe.
@idelpivnitskiy idelpivnitskiy force-pushed the SingleConcatWithPublisher branch from c51e8ae to 5e75613 Compare June 25, 2021 15:49
@idelpivnitskiy idelpivnitskiy requested a review from bondolo June 25, 2021 18:55
Motivation:

Having it after causes a problem that demand may not propagate correctly
@idelpivnitskiy idelpivnitskiy merged commit 4bf0a96 into apple:main Jul 2, 2021
@idelpivnitskiy idelpivnitskiy deleted the SingleConcatWithPublisher branch July 2, 2021 00:12
bondolo pushed a commit to bondolo/servicetalk that referenced this pull request Jul 2, 2021
…sted (apple#1643)

Motivation:

Current version of `Single.concat(Publisher)` subscribes to the next
`Publisher` as soon as the `Single` completes. If the passed `Publisher`
does not support multiple subscribes, users can not apply retries if the
further processing of the single result fails.

Modifications:

- Add `Single.concat(Publisher, boolean)` overload that tells if we
need to subscribe to the next `Publisher` asap or defer subscribe until
more items are requested;
- Implement another `ConcatDeferNextSubscriber` variant that defers
subscribe to the next publisher, share common code in
`AbstractConcatSubscriber`;
- Enhance tests for new operator variant;

Result:

If processing of the first item failed and no more items were requested,
it's safe to apply retry operator even with a `Publisher` that do not
support re-subscribe.
bondolo pushed a commit to bondolo/servicetalk that referenced this pull request Jul 2, 2021
…sted (apple#1643)

Motivation:

Current version of `Single.concat(Publisher)` subscribes to the next
`Publisher` as soon as the `Single` completes. If the passed `Publisher`
does not support multiple subscribes, users can not apply retries if the
further processing of the single result fails.

Modifications:

- Add `Single.concat(Publisher, boolean)` overload that tells if we
need to subscribe to the next `Publisher` asap or defer subscribe until
more items are requested;
- Implement another `ConcatDeferNextSubscriber` variant that defers
subscribe to the next publisher, share common code in
`AbstractConcatSubscriber`;
- Enhance tests for new operator variant;

Result:

If processing of the first item failed and no more items were requested,
it's safe to apply retry operator even with a `Publisher` that do not
support re-subscribe.
Sign up for free to 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.

2 participants