{"action":"created","issue":{"url":"https://api.github.com/repos/akka/akka/issues/23895","repository_url":"https://api.github.com/repos/akka/akka","labels_url":"https://api.github.com/repos/akka/akka/issues/23895/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/23895/comments","events_url":"https://api.github.com/repos/akka/akka/issues/23895/events","html_url":"https://github.com/akka/akka/issues/23895","id":270257554,"number":23895,"title":"Consider pre-packaging the \"PreMaterialize\" pattern (we could late optimize it too)","user":{"login":"ktoso","id":120979,"avatar_url":"https://avatars1.githubusercontent.com/u/120979?v=4","gravatar_id":"","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"labels":[{"id":93144690,"url":"https://api.github.com/repos/akka/akka/labels/t:stream","name":"t:stream","color":"cccccc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-01T10:08:44Z","updated_at":"2017-11-01T10:09:08Z","closed_at":null,"author_association":"OWNER","body":"Pretty sure not many people can ad-hoc whip up this pattern to get a materialized value powered source to emit an entity yet it's very useful in practice:\r\n\r\nexample:\r\n\r\n```scala\r\n    val introspector = path(\"introspector\") {\r\n      concat(\r\n        path(Segment / \"inspect\") { id ⇒\r\n          val refSource = Source.actorRef[ReplicatedIntrospector.Event](Int.MaxValue, OverflowStrategy.fail)\r\n            .map(_.render)\r\n\r\n          // TODO \"pre-materialize pattern\"\r\n          val (ref, pub) =refSource.toMat(Sink.asPublisher(true))(Keep.both).run()\r\n          val s = Source.fromPublisher(pub)\r\n            .intersperse(\"\\n\")\r\n            .map(ByteString(_))\r\n          // end of \"pre-materialize pattern\"\r\n\r\n          introspectorProxy.tell(ReplicatedIntrospector.Inspect, ref)\r\n          \r\n          complete(HttpResponse(entity = HttpEntity(ContentTypes.`text/plain(UTF-8)`, s)))\r\n        }\r\n      )\r\n    }\r\n\r\n```\r\n\r\nI think we should be able to pre-build such a thing perhaps, document it as pre-materialize something and allow users to use it thanks to that rather than have them re-invent this pattern"},"comment":{"url":"https://api.github.com/repos/akka/akka/issues/comments/341061163","html_url":"https://github.com/akka/akka/issues/23895#issuecomment-341061163","issue_url":"https://api.github.com/repos/akka/akka/issues/23895","id":341061163,"user":{"login":"ktoso","id":120979,"avatar_url":"https://avatars1.githubusercontent.com/u/120979?v=4","gravatar_id":"","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"created_at":"2017-11-01T10:09:08Z","updated_at":"2017-11-01T10:09:08Z","author_association":"OWNER","body":"Example is HTTP, though the use case is \"materialized value powered source\" so opened for streams"}}
{"actor":{"display_login":"ktoso"}}