format source with scalafmt
This commit is contained in:
parent
0f40491d42
commit
ce404e4f53
1669 changed files with 43208 additions and 35404 deletions
|
|
@ -20,11 +20,7 @@ class CompositionDocSpec extends AkkaSpec {
|
|||
|
||||
"nonnested flow" in {
|
||||
//#non-nested-flow
|
||||
Source.single(0)
|
||||
.map(_ + 1)
|
||||
.filter(_ != 0)
|
||||
.map(_ - 2)
|
||||
.to(Sink.fold(0)(_ + _))
|
||||
Source.single(0).map(_ + 1).filter(_ != 0).map(_ - 2).to(Sink.fold(0)(_ + _))
|
||||
|
||||
// ... where is the nesting?
|
||||
//#non-nested-flow
|
||||
|
|
@ -33,17 +29,20 @@ class CompositionDocSpec extends AkkaSpec {
|
|||
"nested flow" in {
|
||||
//#nested-flow
|
||||
val nestedSource =
|
||||
Source.single(0) // An atomic source
|
||||
Source
|
||||
.single(0) // An atomic source
|
||||
.map(_ + 1) // an atomic processing stage
|
||||
.named("nestedSource") // wraps up the current Source and gives it a name
|
||||
|
||||
val nestedFlow =
|
||||
Flow[Int].filter(_ != 0) // an atomic processing stage
|
||||
Flow[Int]
|
||||
.filter(_ != 0) // an atomic processing stage
|
||||
.map(_ - 2) // another atomic processing stage
|
||||
.named("nestedFlow") // wraps up the Flow, and gives it a name
|
||||
|
||||
val nestedSink =
|
||||
nestedFlow.to(Sink.fold(0)(_ + _)) // wire an atomic sink to the nestedFlow
|
||||
nestedFlow
|
||||
.to(Sink.fold(0)(_ + _)) // wire an atomic sink to the nestedFlow
|
||||
.named("nestedSink") // wrap it up
|
||||
|
||||
// Create a RunnableGraph
|
||||
|
|
@ -53,17 +52,20 @@ class CompositionDocSpec extends AkkaSpec {
|
|||
|
||||
"reusing components" in {
|
||||
val nestedSource =
|
||||
Source.single(0) // An atomic source
|
||||
Source
|
||||
.single(0) // An atomic source
|
||||
.map(_ + 1) // an atomic processing stage
|
||||
.named("nestedSource") // wraps up the current Source and gives it a name
|
||||
|
||||
val nestedFlow =
|
||||
Flow[Int].filter(_ != 0) // an atomic processing stage
|
||||
Flow[Int]
|
||||
.filter(_ != 0) // an atomic processing stage
|
||||
.map(_ - 2) // another atomic processing stage
|
||||
.named("nestedFlow") // wraps up the Flow, and gives it a name
|
||||
|
||||
val nestedSink =
|
||||
nestedFlow.to(Sink.fold(0)(_ + _)) // wire an atomic sink to the nestedFlow
|
||||
nestedFlow
|
||||
.to(Sink.fold(0)(_ + _)) // wire an atomic sink to the nestedFlow
|
||||
.named("nestedSink") // wrap it up
|
||||
|
||||
//#reuse
|
||||
|
|
@ -192,7 +194,9 @@ class CompositionDocSpec extends AkkaSpec {
|
|||
|
||||
//#mat-combine-2
|
||||
// Materializes to NotUsed (orange)
|
||||
val flow2: Flow[Int, ByteString, NotUsed] = Flow[Int].map { i => ByteString(i.toString) }
|
||||
val flow2: Flow[Int, ByteString, NotUsed] = Flow[Int].map { i =>
|
||||
ByteString(i.toString)
|
||||
}
|
||||
|
||||
// Materializes to Future[OutgoingConnection] (yellow)
|
||||
val flow3: Flow[ByteString, ByteString, Future[OutgoingConnection]] =
|
||||
|
|
@ -217,9 +221,7 @@ class CompositionDocSpec extends AkkaSpec {
|
|||
def close() = p.trySuccess(None)
|
||||
}
|
||||
|
||||
def f(
|
||||
p: Promise[Option[Int]],
|
||||
rest: (Future[OutgoingConnection], Future[String])): Future[MyClass] = {
|
||||
def f(p: Promise[Option[Int]], rest: (Future[OutgoingConnection], Future[String])): Future[MyClass] = {
|
||||
|
||||
val connFuture = rest._1
|
||||
connFuture.map(MyClass(p, _))
|
||||
|
|
@ -235,17 +237,17 @@ class CompositionDocSpec extends AkkaSpec {
|
|||
//#attributes-inheritance
|
||||
import Attributes._
|
||||
val nestedSource =
|
||||
Source.single(0)
|
||||
.map(_ + 1)
|
||||
.named("nestedSource") // Wrap, no inputBuffer set
|
||||
Source.single(0).map(_ + 1).named("nestedSource") // Wrap, no inputBuffer set
|
||||
|
||||
val nestedFlow =
|
||||
Flow[Int].filter(_ != 0)
|
||||
Flow[Int]
|
||||
.filter(_ != 0)
|
||||
.via(Flow[Int].map(_ - 2).withAttributes(inputBuffer(4, 4))) // override
|
||||
.named("nestedFlow") // Wrap, no inputBuffer set
|
||||
|
||||
val nestedSink =
|
||||
nestedFlow.to(Sink.fold(0)(_ + _)) // wire an atomic sink to the nestedFlow
|
||||
nestedFlow
|
||||
.to(Sink.fold(0)(_ + _)) // wire an atomic sink to the nestedFlow
|
||||
.withAttributes(name("nestedSink") and inputBuffer(3, 3)) // override
|
||||
//#attributes-inheritance
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue