private static <T> Graph<SinkShape<T>, NotUsed> createConsumerLoadBalancer(final Collection<ActorRef> routees) { return GraphDSL.create(builder -> { final UniformFanOutShape<T, T> loadBalancer = builder.add(Balance.create(routees.size())); int i = 0; for (final ActorRef routee : routees) { final Sink<Object, NotUsed> sink = Sink.actorRefWithAck(routee, ConsumerStreamMessage.STREAM_STARTED, ConsumerStreamMessage.STREAM_ACK, ConsumerStreamMessage.STREAM_ENDED, error -> ConsumerStreamMessage.STREAM_ENDED); final SinkShape<Object> sinkShape = builder.add(sink); final Outlet<T> outlet = loadBalancer.out(i++); builder.from(outlet).to(sinkShape); } return SinkShape.of(loadBalancer.in()); }); }
private static <T> Graph<SinkShape<T>, NotUsed> createConsumerLoadBalancer(final Collection<ActorRef> routees) { return GraphDSL.create(builder -> { final UniformFanOutShape<T, T> loadBalancer = builder.add(Balance.create(routees.size())); int i = 0; for (final ActorRef routee : routees) { final Sink<Object, NotUsed> sink = Sink.actorRefWithAck(routee, ConsumerStreamMessage.STREAM_STARTED, ConsumerStreamMessage.STREAM_ACK, ConsumerStreamMessage.STREAM_ENDED, error -> ConsumerStreamMessage.STREAM_ENDED); final SinkShape<Object> sinkShape = builder.add(sink); final Outlet<T> outlet = loadBalancer.out(i++); builder.from(outlet).to(sinkShape); } return SinkShape.of(loadBalancer.in()); }); }
builder.from(searchFilter.out1()).toInlet(sudoSearchFilter.in()); builder.from(sudoSearchFilter.out0()).toInlet(fanIn.in1()); builder.from(fanIn.out()).to(sinkToSearchActor);
builder.from(retrieveThingsFilter.out1()).toInlet(sudoRetrieveThingsFilter.in()); builder.from(sudoRetrieveThingsFilter.out0()).toInlet(fanIn.in1()); builder.from(fanIn.out()).to(sinkToThingsAggregator);
/** * Attach a sink to the unhandled port of a filter. * * @param filter the filter. * @param unhandled the sink. * @param <A> type of incoming messages. * @param <B> type of messages that pass through the filter. * @return joined flow. */ public static <A, B> Graph<FlowShape<A, B>, NotUsed> joinUnhandledSink( final Graph<FanOutShape2<A, B, A>, NotUsed> filter, final Graph<SinkShape<A>, NotUsed> unhandled) { return GraphDSL.create(builder -> { final FanOutShape2<A, B, A> filterShape = builder.add(filter); final SinkShape<A> sinkShape = builder.add(unhandled); builder.from(filterShape.out1()).to(sinkShape); return FlowShape.of(filterShape.in(), filterShape.out0()); }); }
/** * Attach a sink to the output port of a filter. * * @param filter the filter. * @param sink the sink. * @param <A> type of incoming and unhandled messages. * @param <B> type of messages that pass through the filter. * @return joined flow. */ public static <A, B> Graph<FlowShape<A, A>, NotUsed> joinFilteredSink( final Graph<FanOutShape2<A, B, A>, NotUsed> filter, final Graph<SinkShape<B>, NotUsed> sink) { return GraphDSL.create(builder -> { final FanOutShape2<A, B, A> filterShape = builder.add(filter); final SinkShape<B> sinkShape = builder.add(sink); builder.from(filterShape.out0()).to(sinkShape); return FlowShape.of(filterShape.in(), filterShape.out1()); }); }
/** * Attach a sink to the unhandled port of a filter. * * @param filter the filter. * @param unhandled the sink. * @param <A> type of incoming messages. * @param <B> type of messages that pass through the filter. * @return joined flow. */ public static <A, B> Graph<FlowShape<A, B>, NotUsed> joinUnhandledSink( final Graph<FanOutShape2<A, B, A>, NotUsed> filter, final Graph<SinkShape<A>, NotUsed> unhandled) { return GraphDSL.create(builder -> { final FanOutShape2<A, B, A> filterShape = builder.add(filter); final SinkShape<A> sinkShape = builder.add(unhandled); builder.from(filterShape.out1()).to(sinkShape); return FlowShape.of(filterShape.in(), filterShape.out0()); }); }
/** * Attach a sink to the output port of a filter. * * @param filter the filter. * @param sink the sink. * @param <A> type of incoming and unhandled messages. * @param <B> type of messages that pass through the filter. * @return joined flow. */ public static <A, B> Graph<FlowShape<A, A>, NotUsed> joinFilteredSink( final Graph<FanOutShape2<A, B, A>, NotUsed> filter, final Graph<SinkShape<B>, NotUsed> sink) { return GraphDSL.create(builder -> { final FanOutShape2<A, B, A> filterShape = builder.add(filter); final SinkShape<B> sinkShape = builder.add(sink); builder.from(filterShape.out0()).to(sinkShape); return FlowShape.of(filterShape.in(), filterShape.out1()); }); }
/** * Join a flow into a sink. * * @param step1 the flow. * @param step2 the sink. * @param <A> type of input. * @param <B> type of intermediate messages. * @return joined sink. */ public static <A, B> Graph<SinkShape<A>, NotUsed> joinSink( final Graph<FlowShape<A, B>, NotUsed> step1, final Graph<SinkShape<B>, NotUsed> step2) { return GraphDSL.create(builder -> { final FlowShape<A, B> shape1 = builder.add(step1); final SinkShape<B> shape2 = builder.add(step2); builder.from(shape1.out()).to(shape2); return SinkShape.of(shape1.in()); }); }
/** * Join a flow into a sink. * * @param step1 the flow. * @param step2 the sink. * @param <A> type of input. * @param <B> type of intermediate messages. * @return joined sink. */ public static <A, B> Graph<SinkShape<A>, NotUsed> joinSink( final Graph<FlowShape<A, B>, NotUsed> step1, final Graph<SinkShape<B>, NotUsed> step2) { return GraphDSL.create(builder -> { final FlowShape<A, B> shape1 = builder.add(step1); final SinkShape<B> shape2 = builder.add(step2); builder.from(shape1.out()).to(shape2); return SinkShape.of(shape1.in()); }); }