reactor / reactor-core

Non-Blocking Reactive Foundation for the JVM
http://projectreactor.io
Apache License 2.0
4.93k stars 1.19k forks source link

Feature/3340 Add best-effort replay sink #3798

Closed MikkelHJuul closed 2 months ago

MikkelHJuul commented 5 months ago

This PR adds the ArraySizeBoundReplayBuffer, and links it for the user via Sink.many().replay().bestEffort().

This new spec offer support for the purely size-bound buffer implementations. It adds #limit(n), #latest() and #latestOrDefault(T), reflecting the same methods from its parent, Sink.many().replay(). The ArraySizeBoundReplayBuffer in contrast to the SizeBoundReplayBuffer will never hold more than the stated items referenced. The SizeBoundReplayBuffer, through the Subscription, will retain old references, such that they can be replayed to the subscriber. This is very correct, but can also make the buffer grow beyond its bounds, if a subscriber lacks request they will still be able to replay all elements, but these elements remain in memory. The ArraySizeBoundReplayBuffer hold and replay only what is kept in the array.

Fixes issues/3340

MikkelHJuul commented 5 months ago

I still need a few tests to document this further

MikkelHJuul commented 4 months ago

I'm having pipeline issues with gradle on M1 Mac, so I'm stuck

chemicL commented 2 months ago

Closing as explained in https://github.com/reactor/reactor-core/issues/3340#issuecomment-2242821598.