-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Closed
Copy link
Labels
help wantedIssues that the core team will likely not have time to work onIssues that the core team will likely not have time to work ont:stream
Milestone
Description
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:
example:
val introspector = path("introspector") {
concat(
path(Segment / "inspect") { id ⇒
val refSource = Source.actorRef[ReplicatedIntrospector.Event](Int.MaxValue, OverflowStrategy.fail)
.map(_.render)
// TODO "pre-materialize pattern"
val (ref, pub) =refSource.toMat(Sink.asPublisher(true))(Keep.both).run()
val s = Source.fromPublisher(pub)
.intersperse("\n")
.map(ByteString(_))
// end of "pre-materialize pattern"
introspectorProxy.tell(ReplicatedIntrospector.Inspect, ref)
complete(HttpResponse(entity = HttpEntity(ContentTypes.`text/plain(UTF-8)`, s)))
}
)
}
I 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
Metadata
Metadata
Assignees
Labels
help wantedIssues that the core team will likely not have time to work onIssues that the core team will likely not have time to work ont:stream