!str - replaces flattenConcat with flatMapConcat
This commit is contained in:
parent
1378fedad0
commit
50c6f2267c
22 changed files with 112 additions and 96 deletions
|
|
@ -60,8 +60,7 @@ private[http] object OutgoingConnectionBlueprint {
|
|||
|
||||
val requestRendering: Flow[HttpRequest, ByteString, Unit] = Flow[HttpRequest]
|
||||
.map(RequestRenderingContext(_, hostHeader))
|
||||
.via(Flow[RequestRenderingContext].map(requestRendererFactory.renderToSource).named("renderer"))
|
||||
.flattenConcat()
|
||||
.via(Flow[RequestRenderingContext].flatMapConcat(requestRendererFactory.renderToSource).named("renderer"))
|
||||
|
||||
val methodBypass = Flow[HttpRequest].map(_.method)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import akka.http.impl.util._
|
|||
import akka.http.scaladsl.Http
|
||||
import akka.http.scaladsl.model._
|
||||
import akka.stream._
|
||||
import akka.stream.impl.ConstantFun
|
||||
import akka.stream.io._
|
||||
import akka.stream.scaladsl._
|
||||
import akka.stream.stage._
|
||||
|
|
@ -108,7 +109,7 @@ private[http] object HttpServerBluePrint {
|
|||
Flow[ResponseRenderingContext]
|
||||
.via(Flow[ResponseRenderingContext].transform(() ⇒ new ErrorsTo500ResponseRecovery(log)).named("recover")) // FIXME: simplify after #16394 is closed
|
||||
.via(Flow[ResponseRenderingContext].transform(() ⇒ responseRendererFactory.newRenderer).named("renderer"))
|
||||
.flattenConcat()
|
||||
.flatMapConcat(ConstantFun.scalaIdentityFunction)
|
||||
.via(Flow[ResponseRenderingOutput].transform(() ⇒ errorLogger(log, "Outgoing response stream error")).named("errorLogger"))
|
||||
|
||||
BidiFlow.fromGraph(FlowGraph.create(requestParsingFlow, rendererPipeline, oneHundredContinueSource)((_, _, _) ⇒ ()) { implicit b ⇒
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ private[http] object MessageToFrameRenderer {
|
|||
Source.single(FrameEvent.emptyLastContinuationFrame)
|
||||
|
||||
Flow[Message]
|
||||
.map {
|
||||
.flatMapConcat {
|
||||
case BinaryMessage.Strict(data) ⇒ strictFrames(Opcode.Binary, data)
|
||||
case bm: BinaryMessage ⇒ streamedFrames(Opcode.Binary, bm.dataStream)
|
||||
case TextMessage.Strict(text) ⇒ strictFrames(Opcode.Text, ByteString(text, "UTF-8"))
|
||||
case tm: TextMessage ⇒ streamedFrames(Opcode.Text, tm.textStream.transform(() ⇒ new Utf8Encoder))
|
||||
}.flattenConcat()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,12 +49,11 @@ package object util {
|
|||
|
||||
private[http] def headAndTailFlow[T]: Flow[Source[T, Any], (T, Source[T, Unit]), Unit] =
|
||||
Flow[Source[T, Any]]
|
||||
.map {
|
||||
.flatMapConcat {
|
||||
_.prefixAndTail(1)
|
||||
.filter(_._1.nonEmpty)
|
||||
.map { case (prefix, tail) ⇒ (prefix.head, tail) }
|
||||
}
|
||||
.flattenConcat()
|
||||
|
||||
private[http] def printEvent[T](marker: String): Flow[T, T, Unit] =
|
||||
Flow[T].transform(() ⇒ new PushPullStage[T, T] {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package akka.http.scaladsl.model
|
|||
import java.io.File
|
||||
|
||||
import akka.event.{ NoLogging, LoggingAdapter }
|
||||
import akka.stream.impl.ConstantFun
|
||||
|
||||
import scala.collection.immutable.VectorBuilder
|
||||
import scala.concurrent.duration.FiniteDuration
|
||||
|
|
@ -40,7 +41,7 @@ sealed trait Multipart {
|
|||
val chunks =
|
||||
parts
|
||||
.transform(() ⇒ BodyPartRenderer.streamed(boundary, charset.nioCharset, partHeadersSizeHint = 128, log))
|
||||
.flattenConcat()
|
||||
.flatMapConcat(ConstantFun.scalaIdentityFunction)
|
||||
HttpEntity.Chunked(mediaType withBoundary boundary, chunks)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -531,7 +531,7 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
|
|||
Right(HttpRequest(method, uri, headers, createEntity(entityParts), protocol))
|
||||
case (x @ (MessageStartError(_, _) | EntityStreamError(_)), _) ⇒ Left(x)
|
||||
}
|
||||
.map { x ⇒
|
||||
.flatMapConcat { x ⇒
|
||||
Source {
|
||||
x match {
|
||||
case Right(request) ⇒ compactEntity(request.entity).fast.map(x ⇒ Right(request.withEntity(x)))
|
||||
|
|
@ -539,7 +539,6 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
|
|||
}
|
||||
}
|
||||
}
|
||||
.flattenConcat()
|
||||
.map(strictEqualify)
|
||||
.grouped(100000).runWith(Sink.head)
|
||||
.awaitResult(awaitAtMost)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue