Java Code Examples for akka.stream.javadsl.Flow#create()
The following examples show how to use
akka.stream.javadsl.Flow#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Pipe.java From ditto with Eclipse Public License 2.0 | 5 votes |
/** * Chain a collection of flows one after another. * * @param flows collection of flows. * @param <A> type of messages through the flows. * @return joined flow. */ public static <A> Graph<FlowShape<A, A>, NotUsed> joinFlows( final Collection<Graph<FlowShape<A, A>, NotUsed>> flows) { Flow<A, A, NotUsed> overallFlow = Flow.create(); for (Graph<FlowShape<A, A>, NotUsed> flow : flows) { overallFlow = overallFlow.via(flow); } return overallFlow; }
Example 2
Source File: AbstractRoute.java From ditto with Eclipse Public License 2.0 | 5 votes |
/** * Interpret a throttling config and throttle a stream with it. * * @param throttlingConfig the throttling config to interpret. * @param <T> type of elements in the stream. * @return a throttling flow. * @since 1.1.0 */ public static <T> Flow<T, T, NotUsed> throttleByConfig(final ThrottlingConfig throttlingConfig) { final int limit = throttlingConfig.getLimit(); final Duration interval = throttlingConfig.getInterval(); if (limit > 0 && interval.negated().isNegative()) { return Flow.<T>create().throttle(throttlingConfig.getLimit(), throttlingConfig.getInterval()); } else { return Flow.create(); } }
Example 3
Source File: MongoSearchUpdaterFlow.java From ditto with Eclipse Public License 2.0 | 5 votes |
/** * Create a new flow through the search persistence. * No logging or recovery is attempted. * * @param parallelism How many write operations may run in parallel for this sink. * @param maxBulkSize How many writes to perform in one bulk. * @param writeInterval Delay between bulk operation requests. MongoDB backpressure is insufficient. * @return the sink. */ public Flow<Source<AbstractWriteModel, NotUsed>, WriteResultAndErrors, NotUsed> start( final int parallelism, final int maxBulkSize, final Duration writeInterval) { final Flow<List<AbstractWriteModel>, List<AbstractWriteModel>, NotUsed> throttleFlow; if (Duration.ZERO.minus(writeInterval).isNegative()) { throttleFlow = Flow.<List<AbstractWriteModel>>create() .delay(writeInterval, DelayOverflowStrategy.backpressure()); } else { throttleFlow = Flow.create(); } final Flow<Source<AbstractWriteModel, NotUsed>, List<AbstractWriteModel>, NotUsed> batchFlow = Flow.<Source<AbstractWriteModel, NotUsed>>create() .flatMapConcat(source -> source.grouped(maxBulkSize)) .via(throttleFlow); final Flow<List<AbstractWriteModel>, WriteResultAndErrors, NotUsed> writeFlow = Flow.<List<AbstractWriteModel>>create() .flatMapMerge(parallelism, this::executeBulkWrite) // never initiate more than "parallelism" writes against the persistence .withAttributes(Attributes.inputBuffer(parallelism, parallelism)); return Flow.fromGraph(assembleFlows(batchFlow, writeFlow, createStartTimerFlow(), createStopTimerFlow())); }
Example 4
Source File: EnforcerActor.java From ditto with Eclipse Public License 2.0 | 4 votes |
@Override protected Flow<Contextual<WithDittoHeaders>, Contextual<WithDittoHeaders>, NotUsed> processMessageFlow() { return Flow.create(); }
Example 5
Source File: EventSniffer.java From ditto with Eclipse Public License 2.0 | 4 votes |
@Override public Flow<T, T, NotUsed> toAsyncFlow(final HttpRequest request) { return Flow.create(); }