本文整理匯總了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();
}