-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Discard vs. Drop #2103
Comments
Unfortunately, it seems too late to address that one in time for 3.4, considering how late we already are in the pre-release cycle. Thus I'm moving this to 3.5 planning. |
Any update? |
@simonbasle @chemicL I think it is a good oportunity to deprecate Operators.onNextDropped for 3.5.0 while making it private in 3.6 |
a bit of context on #3229 being closed (as discussed off-band): this wasn't likely addressing the right issue or using the right angle. so a preferable solution would be to introduce a dedicated global hook in finally, convey the message that global |
It's been a while and me and @violetagg are not convinced by this proposal. The assumption of discarding/dropping being idempotent would most probably not hold in reference counted objects as there is no checking of who and why is doing the decrement. That could invalidate further processing. Therefore, it feels this idea seems dangerous. The API and the behaviour have been considered stable for quite some time and it is a very risky area to touch. If new requirements arise we can come back to this idea. |
problem
It seems that similar issues were raised in the past, but I feel I'm not convinced enough to agree.
It seems (from @smaldini words from Better names for onNextDropped vs doOnDiscard hooks, compose/transform, doOnEach #1381) that onNextDropped is a spec violation which is incorrect.
FluxTake
. It does take N elements, cancel subscription upon receiving the expected number of elements to take, and set the state todone
. It means that in the case of racing between CANCEL and ON_NEXT more signals can appear (imaging.cancelOn
up the stream which delays a little bit cancellation) which leads that few elements can be dropped easily (which is absolutely valid case due to 2.8).onNextDropped
IS DESIGNED TO HANDLE unexpected along with racing between cancellation and onNext signals.Now we have another operator to handle filtered (discarded) elements on the level of the local stream, BUT it has significant design FLAW:
Mono
(or even from flux perspective) where we constantly have 3-4 objects overhead (FluxContextStart + ContextStartSubscriber + Consumer<? super R> discardHook + createdContext
) is WAY expensive (💔)proposal
The only way to make it consistent is to merge both drop and discard APIs and make them interconnected, e.g if no local hooks discard hooks installed, we are free to lookup for global hooks. Since
Operators.onNextDrop
is, let's call it, internal API, I don't see any problem to UNIFY that in 3.4The text was updated successfully, but these errors were encountered: