Skip to content

Akka.Streams: add PreMaterialize support for Sources #3476

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

Merged

Conversation

Aaronontheweb
Copy link
Member

Port of akka/akka#24497

@Aaronontheweb Aaronontheweb added this to the 1.3.8 milestone May 30, 2018
@Horusiath Horusiath self-requested a review May 30, 2018 16:47

### Source pre-materialization
There are situations in which you require a `Source` materialized value **before** the `Source` gets hooked up to the rest of the graph.
+This is particularly useful in the case of "materialized value powered" `Source`s, like `Source.Queue`, `Source.ActorRef` or `Source.Maybe`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A + too much

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, good catch.

Tuple<TaskCompletionSource<int>, Source<int>> materialized = matValPoweredSource.PreMaterialize(Sys.Materializer());
var tcs = materialized.Item1;
var nextSource = materialized.Item2;
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s probably fine to include this code directly in the .md since all the other code examples are here as well, but in general haven’t we agreed on using the document projects for code examples ?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcpiechura yeah, we try to do that for the most part going forward but we don't have anything organized for that in Akka.Streams itself at the moment. I'd personally prefer to do something that is compile-time checked and there referred to via DocFx's source code embedding, akin to https://github.com/akka/akka/pull/24497/files#diff-96bb38a1bfc1933567a890af8f3d0263

But starting the infrastructure for that is a bigger project than adding just this one feature. So question for you is: start building the infrastructure now or throw yet one more thing on the future technical debt pile for later? I'm opted for the latter (obviously) but, if there's buy-in from other folks to go down the route of doing something similar to what the JVM does then I'd be all for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp, I was wrong about this - we do have support for this built into the project already. Just uploaded some changes which incorporate it.

@Aaronontheweb
Copy link
Member Author

@marcpiechura I think I addressed all of your comments in the newest commit.

@marcpiechura
Copy link
Contributor

@Aaronontheweb there is still the ++ in the readme ;-)

@Aaronontheweb
Copy link
Member Author

@marcpiechura damn, thought I got it - just fixed... again :p

@marcpiechura marcpiechura merged commit c2c1df0 into akkadotnet:dev May 31, 2018
@Aaronontheweb Aaronontheweb deleted the akka-streams-pre-materialize branch May 31, 2018 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants