Skip to content

Commit

Permalink
Fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasMikula committed Feb 28, 2019
1 parent a5baa1e commit 608fdb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
11 changes: 5 additions & 6 deletions contrib/src/main/scala/akka/stream/contrib/PartitionWith.scala
Expand Up @@ -43,12 +43,11 @@ object PartitionWith {
* Partition the output of the decorated flow according to the given partition function. * Partition the output of the decorated flow according to the given partition function.
*/ */
def partitionWith[Out0, Out1](p: Out => Either[Out0, Out1]): Graph[FanOutShape2[In, Out0, Out1], M] = { def partitionWith[Out0, Out1](p: Out => Either[Out0, Out1]): Graph[FanOutShape2[In, Out0, Out1], M] = {
GraphDSL.create(flowGraph, PartitionWith(p))(Keep.left) { implicit builder => GraphDSL.create(flowGraph, PartitionWith(p))(Keep.left) { implicit builder => (flow, fanOut) => {
(flow, fanOut) => { import GraphDSL.Implicits._
import GraphDSL.Implicits._ flow.out ~> fanOut.in
flow.out ~> fanOut.in new FanOutShape2(flow.in, fanOut.out0, fanOut.out1)
new FanOutShape2(flow.in, fanOut.out0, fanOut.out1) }
}
} }
} }
} }
Expand Down
18 changes: 8 additions & 10 deletions contrib/src/test/scala/akka/stream/contrib/PartitionWithSpec.scala
Expand Up @@ -14,17 +14,16 @@ class PartitionWithSpecAutoFusingOff extends { val autoFusing = false } with Par
trait PartitionWithSpec extends BaseStreamSpec { trait PartitionWithSpec extends BaseStreamSpec {


private def mergeFanOut[I, O, M](fanOutGraph: Graph[FanOutShape2[I, O, O], M]): Flow[I, O, M] = { private def mergeFanOut[I, O, M](fanOutGraph: Graph[FanOutShape2[I, O, O], M]): Flow[I, O, M] = {
Flow.fromGraph(GraphDSL.create(fanOutGraph){ implicit builder => Flow.fromGraph(GraphDSL.create(fanOutGraph) { implicit builder => fanOut => {
fanOut => { import GraphDSL.Implicits._
import GraphDSL.Implicits._


val mrg = builder.add(Merge[O](2)) val mrg = builder.add(Merge[O](2))


fanOut.out0 ~> mrg.in(0) fanOut.out0 ~> mrg.in(0)
fanOut.out1 ~> mrg.in(1) fanOut.out1 ~> mrg.in(1)


FlowShape(fanOut.in, mrg.out) FlowShape(fanOut.in, mrg.out)
} }
}) })
} }


Expand Down Expand Up @@ -103,8 +102,7 @@ trait PartitionWithSpec extends BaseStreamSpec {
import PartitionWith.Implicits._ import PartitionWith.Implicits._


val flow = mergeFanOut( val flow = mergeFanOut(
Flow[Int].partitionWith(i => if (i % 2 == 0) Left(-i) else Right(i)) Flow[Int].partitionWith(i => if (i % 2 == 0) Left(-i) else Right(i)))
)


val (source, sink) = TestSource.probe[Int] val (source, sink) = TestSource.probe[Int]
.via(flow) .via(flow)
Expand Down

0 comments on commit 608fdb7

Please sign in to comment.