-
Notifications
You must be signed in to change notification settings - Fork 77
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
FlowEnrichment stage #50
Comments
I'd be very happy to see that actually. Seen such patterns in big data things before but noone had a nice api for it. Interesting idea would be: Source.single("name" -> 42)
.focusOn(_._2)
.map(_ + 58) // could these be SubFlow/Source?
.filter(_ > 10) // could these be SubFlow/Source?
.unfocus
.map { case (name, num) => s"$name -> $num" } |
I'll upload the code and open a PR later, so you can have a look. The current API looks like this:
|
Perhaps exact syntax of focusOn is unachievable, but I think the feature should be possible. We need the It would be fun to see if we could use techniques from lenses here, see: https://github.com/julien-truffaut/Monocle |
Ooh, good idea. I'll try to see if I can make it work. (Just to be clear, you don't mean to actually use Monocle/catz/whatever, right?) |
We could, if it turns out to be awesome might be very fun project. Simple one would be nice anyway, and perhaps then the more generic monocle-powered version |
Issues are many-to-many Flows (this have been considered before). It might work in some cases but be aware of the issue. |
@ktoso @drewhk |
@ktoso I got focus/unfocus to work, but without support for materialized values (inner flow is always materialized to NotUsed). The latest commit in the branch(77a8f63) is the one without materialization, the commit before that(14e4fa7) is my initial attempt to handle materialization. The problem is that while the inner flow is being constructed, the original source/flow is not yet connected to the inner flow, so I couldn't get the types (and semantics) to line up. It's probably possible by making a new shape, and then importing the source/flow into it, but I'll have to fiddle with it some more and see where I get. What do you think? |
Cool! Could you submit that branch as a PR? It's easier to comment and check out this way :) |
More discussion that may be relevant: akka/akka#15957 |
While working with akka-streams, I had a couple of flows where I had, for example, a (id, message) tuple but the ID was just carried along the stream. Everything in the stream itself (maps and filters, mostly) only cared about the message. The resulting code was pretty ugly (pattern matching the tuple at every point, with type annotations since the type-inference went haywire), and so I wrote a GraphStage that wraps a Flow and adds/removes the ID.
Do you think this is something that can be added here?
The text was updated successfully, but these errors were encountered: