-
Notifications
You must be signed in to change notification settings - Fork 159
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
Feature request: Add Flow#switchMap operator. #974
Comments
@pjfanning @mdedetrich what do you think about his one, I find it would be nice for live streaming. |
Implementation this shold not be that hard but seems no much interest, will defer to later version. it's a kind of stream of streams |
I think we have enough on our plate right now with all of the new features, we can always add this into 1.1.0-M2 (if a new M2 is needed) or in 1.2.x. |
I will back my hometown soon, if anyone submited a pr about this, then this can be added to 1.1.0-M2 I think, before that, it's safe for later version. I was expecting we stating remove code in 1.2.x but not adding features. I just update what I thought about this operator. |
refs: #1660 |
Flux<ChatResponse> chatResponseFlux = response.switchMap(chatCompletionResponse -> { It's been used in spring-ai |
I used to use this operator a lot when dealing with various applications related to monitoring live data and always missed it when working with akka streams in the past. I'm currently not working on any of such projects - if I were, I'd happily submit a PR (and might as well still do that if I find the time). One thing though: from my experience (I might be biased due to the "live data" use cases I used it for), I'd strongly advocate for "Backpressures when: never." The way this operator works, only the very latest value from upstream should cause items to be emitted to downstream, so there is no sense in keeping anything but that one latest value (and the resulting substream) in the pipeline. |
That's true; this kind of operator will never do any backpressure. |
Motivation:
I find that Pekko stream doen't has the
switchmap
operator, it's called as this in bothfs2
andflux
, I think we need to take the same name and same semantic.Usercase:
A Stream of
Post
, eg twitter/X 's Post, and every Post has a Stream ofComments
.Emits when: sub stream emits and downstream is available
Backpressures when: sub stream backpressure.
cancels when: down stream cancels
completes when: upstream completes and the current substream completes.
In some implementation, the upstream is never backpressured, I think that's not safe. I think the upstream should be backpressured if there is no downstream demands.
Result:
We have rich operators set.
The text was updated successfully, but these errors were encountered: