Create Source from Sink - #25150
Conversation
|
Hi @cedretaber, Thank you for your contribution! We really value the time you've taken to put this together. Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement: |
|
Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK TO TEST' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged. For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask! |
|
OK TO TEST |
|
Test FAILed. |
|
Seems the docs are misplaced, but let's discuss the design first:
|
|
Thank you for your review!
|
|
With regards to I think I like |
df4b894 to
781d9d8
Compare
|
Test FAILed. |
|
Test FAILed. |
|
|
||
| @@@div { .callout } | ||
|
|
||
| @@@ |
There was a problem hiding this comment.
we'd need examples as well, from nowadays we should always right away include examples when we merge new operators. See here how: https://raw.githubusercontent.com/akka/akka/master/akka-docs/src/main/paradox/stream/operators/Sink/actorRefWithAck.md
There was a problem hiding this comment.
Should I create SourceDocSpec.scala , or write the tests in IntegrationDocSpec.scala ?
| .toMat(Sink.asPublisher[M](fanout = false))(Keep.both) | ||
| .mapMaterializedValue { | ||
| case (sub, pub) ⇒ (Sink.fromSubscriber(sub), Source.fromPublisher(pub)) | ||
| } |
There was a problem hiding this comment.
needs to get a javadsl as well, on javadsl.Source
| * > Sink |------>| Source > | ||
| * +----------+ +----------+ | ||
| * | ||
| * Should be provided by Akka Streams, see https://github.com/akka/akka/issues/24853. |
There was a problem hiding this comment.
No need for such comment, this is IN akka streams then after all ;-)
| * +----------+ +----------+ | ||
| * > Sink |------>| Source > | ||
| * +----------+ +----------+ | ||
| * |
There was a problem hiding this comment.
This needs to be put into a
{{{
...
}}}
for formatting reasons
| .toMat(Sink.asPublisher[M](fanout = false))(Keep.both) | ||
| .mapMaterializedValue { | ||
| case (sub, pub) ⇒ (Sink.fromSubscriber(sub), Source.fromPublisher(pub)) | ||
| } |
| * | ||
| * Should be provided by Akka Streams, see https://github.com/akka/akka/issues/24853. | ||
| */ | ||
| def sinkToSource[M]: RunnableGraph[(Sink[M, NotUsed], Source[M, NotUsed])] = |
There was a problem hiding this comment.
We need to ponder the name some more...
I have no good name today in mind though...
There was a problem hiding this comment.
This is the best I can come up with
There was a problem hiding this comment.
Regarding the name: This seems like the opposite of Flow#fromSinkAndSource. It seems like this could live on Flow (the class not the object), the idea would be like breaking an existing flow into a sink and source.
So something like:
class Flow[-In, +Out, +Mat] {
.
.
.
def toSinkAndSource: (Sink[In],Source[Out]) =
Source
.asSubscriber[In]
.via(this)
.toMat(Sink.asPublisher[Out](fanout = false))(Keep.both)
.mapMaterializedValue {
case (sub, pub) ⇒ (Sink.fromSubscriber(sub), Source.fromPublisher(pub))
}.run()
Of course, you have to run it in order to actually get the sink and the source, so that might not be desirable.
|
Test FAILed. |
| * | ||
| * Should be provided by Akka Streams, see https://github.com/akka/akka/issues/24853. | ||
| */ | ||
| def sinkToSource[M]: RunnableGraph[(Sink[M, NotUsed], Source[M, NotUsed])] = |
There was a problem hiding this comment.
Why add this method to Sink? It creates both a sink and source on materialization. I'd rather put it into RunnableGraph.
There was a problem hiding this comment.
RunnableGraph would perhaps make sense but it would be completely undiscoverable as there are no other factories (fromGraph is the only one) there.
| * | ||
| * Should be provided by Akka Streams, see https://github.com/akka/akka/issues/24853. | ||
| */ | ||
| def sinkToSource[M]: RunnableGraph[(Sink[M, NotUsed], Source[M, NotUsed])] = |
There was a problem hiding this comment.
M is typically used for the type of the materialized value. Please change to A or T.
|
@hseeberger |
|
Test FAILed. |
|
Test FAILed. |
|
I'm sorry, but in the present situation I do not have enough energy to discuss and promote this feature. May I close this pull request? I think that who have strong motivation for it should create the pull request again. |
|
no problem, thanks for your efforts |
|
@cedretaber Hi @cedretaber would you like to continue this PR? |
|
@hepin1989 |
Refs #24853
Add
connectto Source.It easily connects a source to a sink, based on #24853 (comment).