!str make Inlet/Outlet invariant and add Java variance

This necessitates the removal of method overloading in the Java Graph
DSL: the to() and via() methods were not otherwise resolved correctly by
javac, leading to incomprehensible error messages. The new approach is
to offer just one way of doing things which is a bit more verbose but
should be easier to read and learn. In this vein auto-importing while
using the DSL is also gone for Java—not sure about Scala yet.
This commit is contained in:
Roland Kuhn 2015-10-08 12:12:35 +02:00
parent c6a5864e25
commit dc07fd250c
23 changed files with 111 additions and 1649 deletions

View file

@ -50,7 +50,7 @@ object BidiFlowDocSpec {
// construct and add the bottom flow, going inbound
val inbound = b.add(Flow[ByteString].map(fromBytes))
// fuse them together into a BidiShape
BidiShape(outbound, inbound)
BidiShape.fromFlows(outbound, inbound)
}
// this is the same as the above
@ -112,18 +112,18 @@ object BidiFlowDocSpec {
val outbound = b.add(Flow[ByteString].map(addLengthHeader))
val inbound = b.add(Flow[ByteString].transform(() => new FrameParser))
BidiShape(outbound, inbound)
BidiShape.fromFlows(outbound, inbound)
}
//#framing
val chopUp = BidiFlow() { b =>
val f = Flow[ByteString].mapConcat(_.map(ByteString(_)))
BidiShape(b.add(f), b.add(f))
BidiShape.fromFlows(b.add(f), b.add(f))
}
val accumulate = BidiFlow() { b =>
val f = Flow[ByteString].grouped(1000).map(_.fold(ByteString.empty)(_ ++ _))
BidiShape(b.add(f), b.add(f))
BidiShape.fromFlows(b.add(f), b.add(f))
}
}