本文整理汇总了Java中akka.stream.Graph类的典型用法代码示例。如果您正苦于以下问题:Java Graph类的具体用法?Java Graph怎么用?Java Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Graph类属于akka.stream包,在下文中一共展示了Graph类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import akka.stream.Graph; //导入依赖的package包/类
/**
* Creates a flow that feeds each event into [selector], and:
* - If the selector emits a result, that result, and further results that also match, are fed through [target], and then merged into the stream.
* - If the selector emits {@link ReadProtocol#none()}, the event is passed downstream unchanged
* - If the selector emits a failure, the stream is failed.
*/
public static <E> Flow<E, E, NotUsed> filter(ReadProtocol<E,E> selector, Graph<FlowShape<E,E>, ?> target) {
return Flow
.<E>create()
.via(insertMarkers(selector))
.splitWhen(Marker.class::isInstance)
.prefixAndTail(1)
.flatMapConcat(t -> {
// This is safe because all of the "tail" in "prefixAndTail" above comes from the original stream of E.
Source<E, NotUsed> source = uncheckedCast(t.second());
return isSelected(t.first().get(0)) ? source.via(target) : source;
})
.concatSubstreams();
}