+str #19390 Add 'monitor' flow combinator and stage

This commit is contained in:
Tal Pressman 2016-02-21 13:03:00 +02:00 committed by Patrik Nordwall
parent bd8fcc9d9a
commit 26c25c89ed
12 changed files with 272 additions and 13 deletions

View file

@ -6,8 +6,8 @@ package akka.stream.javadsl
import akka.{ NotUsed, Done }
import akka.event.LoggingAdapter
import akka.japi.{ function, Pair }
import akka.stream.impl.{ ConstantFun, StreamLayout }
import akka.stream.{ scaladsl, _ }
import akka.stream.impl.{ConstantFun, StreamLayout}
import akka.stream._
import akka.stream.stage.Stage
import org.reactivestreams.Processor
import scala.annotation.unchecked.uncheckedVariance
@ -1686,6 +1686,15 @@ final class Flow[-In, +Out, +Mat](delegate: scaladsl.Flow[In, Out, Mat]) extends
def watchTermination[M]()(matF: function.Function2[Mat, CompletionStage[Done], M]): javadsl.Flow[In, Out, M] =
new Flow(delegate.watchTermination()((left, right) matF(left, right.toJava)))
/**
* Materializes to `FlowMonitor[Out]` that allows monitoring of the the current flow. All events are propagated
* by the monitor unchanged. Note that the monitor inserts a memory barrier every time it processes an
* event, and may therefor affect performance.
* The `combine` function is used to combine the `FlowMonitor` with this flow's materialized value.
*/
def monitor[M]()(combine: function.Function2[Mat, FlowMonitor[Out], M]): javadsl.Flow[In, Out, M] =
new Flow(delegate.monitor()(combinerToScala(combine)))
/**
* Delays the initial element by the specified duration.
*