!str #18692 javadsl.FlowGraph.Builder.add()
* also make factories more consistent by only offering FlowGraph.create() * also remove secondary (edge-based) FlowGraph.Builder DSL * also improve naming for conversions from Graph to Source/Flow/BidiFlow/Sink
This commit is contained in:
parent
0f99a42df9
commit
f29d7affbd
120 changed files with 1535 additions and 1897 deletions
|
|
@ -44,21 +44,21 @@ object BidiFlowDocSpec {
|
|||
}
|
||||
//#codec-impl
|
||||
|
||||
val codecVerbose = BidiFlow() { b =>
|
||||
val codecVerbose = BidiFlow.fromGraph(FlowGraph.create() { b =>
|
||||
// construct and add the top flow, going outbound
|
||||
val outbound = b.add(Flow[Message].map(toBytes))
|
||||
// construct and add the bottom flow, going inbound
|
||||
val inbound = b.add(Flow[ByteString].map(fromBytes))
|
||||
// fuse them together into a BidiShape
|
||||
BidiShape.fromFlows(outbound, inbound)
|
||||
}
|
||||
})
|
||||
|
||||
// this is the same as the above
|
||||
val codec = BidiFlow(toBytes _, fromBytes _)
|
||||
val codec = BidiFlow.fromFunctions(toBytes _, fromBytes _)
|
||||
//#codec
|
||||
|
||||
//#framing
|
||||
val framing = BidiFlow() { b =>
|
||||
val framing = BidiFlow.fromGraph(FlowGraph.create() { b =>
|
||||
implicit val order = ByteOrder.LITTLE_ENDIAN
|
||||
|
||||
def addLengthHeader(bytes: ByteString) = {
|
||||
|
|
@ -113,18 +113,18 @@ object BidiFlowDocSpec {
|
|||
val outbound = b.add(Flow[ByteString].map(addLengthHeader))
|
||||
val inbound = b.add(Flow[ByteString].transform(() => new FrameParser))
|
||||
BidiShape.fromFlows(outbound, inbound)
|
||||
}
|
||||
})
|
||||
//#framing
|
||||
|
||||
val chopUp = BidiFlow() { b =>
|
||||
val chopUp = BidiFlow.fromGraph(FlowGraph.create() { b =>
|
||||
val f = Flow[ByteString].mapConcat(_.map(ByteString(_)))
|
||||
BidiShape.fromFlows(b.add(f), b.add(f))
|
||||
}
|
||||
})
|
||||
|
||||
val accumulate = BidiFlow() { b =>
|
||||
val accumulate = BidiFlow.fromGraph(FlowGraph.create() { b =>
|
||||
val f = Flow[ByteString].grouped(1000).map(_.fold(ByteString.empty)(_ ++ _))
|
||||
BidiShape.fromFlows(b.add(f), b.add(f))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
class BidiFlowDocSpec extends AkkaSpec with ConversionCheckedTripleEquals {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue