-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Create Source from Sink #25150
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for such comment, this is IN akka streams then after all ;-)
* +----------+ +----------+ | ||
* > Sink |------>| Source > | ||
* +----------+ +----------+ | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks fine though :)
* | ||
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to ponder the name some more...
I have no good name today in mind though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the best I can come up with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment
#25150 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
connect
to Source.It easily connects a source to a sink, based on #24853 (comment).