class Http2ServerDemux extends GraphStage[BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream]]
This stage contains all control logic for handling frames and (de)muxing data to/from substreams.
(This is not a final documentation, more like a brain-dump of how it could work.)
The BidiStage consumes and produces FrameEvents from the network. It will output one Http2SubStream for incoming frames per substream and likewise accepts a single Http2SubStream per substream with outgoing frames.
(An alternative API would just push a BidiHttp2SubStream(subStreamFlow: Flow[StreamFrameEvent, StreamFrameEvent]) similarly to IncomingConnection. This would more accurately model the one-to-one relation between incoming and outgoing Http2Substream directions but wouldn't stack so nicely with other BidiFlows.)
Backpressure logic:
* read all incoming frames without applying backpressure * this ensures that all "control" frames are read in a timely manner * though, make sure limits are not exceeded * max connection limit (which limits number of parallel requests) * window sizes for incoming data frames * that means we need to buffer incoming substream data until the user handler (consuming the source in the Http2SubStream) will read it * per-connection and per-stream window updates should reflect how much data was (not) yet passed into the user handler and therefore are the main backpressure mechanism towards the peer * for the outgoing frame side we need to decide which frames to send per incoming demand * control frames (settings, ping, acks, window updates etc.) -> responses to incoming frames * substream frames -> incoming frame data from substreams * to be able to make a decision some data must already be buffered for those two sources of incoming frames
Demultiplexing: * distribute incoming frames to their respective targets: * control frames: handled internally, may generate outgoing control frames directly * incoming HEADERS frames: creates a new Http2SubStream including a SubSource that will receive all upcoming data frames * incoming data frames: buffered and pushed to the SubSource of the respective substream
Multiplexing: * schedule incoming frames from multiple sources to be pushed onto the shared medium * control frames: as generated from the stage itself (should probably preferred over everything else) * Http2SubStream produced by the user handler: read and push initial frame ASAP * outgoing data frames for each of the substreams: will comprise the bulk of the data and is where any clever, prioritizing, etc. i.e. tbd later sending strategies will apply
In the best case we could just flattenMerge the outgoing side (hoping for the best) but this will probably not work because the sending decision relies on dynamic window size and settings information that will be only available in this stage.
- Source
- Http2ServerDemux.scala
- Alphabetic
- By Inheritance
- Http2ServerDemux
- GraphStage
- GraphStageWithMaterializedValue
- Graph
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Http2ServerDemux(http2Settings: Http2ServerSettings)
Type Members
-
type
Shape = BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream]
- Definition Classes
- Graph
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to any2stringadd[Http2ServerDemux] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (Http2ServerDemux, B)
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to ArrowAssoc[Http2ServerDemux] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addAttributes(attr: Attributes): Graph[BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream], NotUsed]
- Definition Classes
- Graph
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
async: Graph[BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream], NotUsed]
- Definition Classes
- Graph
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
createLogic(inheritedAttributes: Attributes): GraphStageLogic
- Definition Classes
- Http2ServerDemux → GraphStage
-
final
def
createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, NotUsed)
- Definition Classes
- GraphStage → GraphStageWithMaterializedValue
-
def
ensuring(cond: (Http2ServerDemux) ⇒ Boolean, msg: ⇒ Any): Http2ServerDemux
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to Ensuring[Http2ServerDemux] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (Http2ServerDemux) ⇒ Boolean): Http2ServerDemux
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to Ensuring[Http2ServerDemux] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): Http2ServerDemux
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to Ensuring[Http2ServerDemux] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): Http2ServerDemux
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to Ensuring[Http2ServerDemux] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to StringFormat[Http2ServerDemux] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
- val frameIn: Inlet[FrameEvent]
- val frameOut: Outlet[FrameEvent]
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
initialAttributes: Attributes
- Attributes
- protected
- Definition Classes
- GraphStageWithMaterializedValue
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
lazy val
module: Module
- Definition Classes
- GraphStageWithMaterializedValue → Graph
-
def
named(name: String): Graph[BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream], NotUsed]
- Definition Classes
- Graph
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
val
shape: BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream]
- Definition Classes
- Http2ServerDemux → Graph
- val substreamIn: Inlet[Http2SubStream]
- val substreamOut: Outlet[Http2SubStream]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
withAttributes(attr: Attributes): Graph[BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream], NotUsed]
- Definition Classes
- GraphStageWithMaterializedValue → Graph
-
def
→[B](y: B): (Http2ServerDemux, B)
- Implicit
- This member is added by an implicit conversion from Http2ServerDemux to ArrowAssoc[Http2ServerDemux] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc