public <D> Accumulator<D, A> through(Flow<D, E, ?> flow) { return new SinkAccumulator<>(flow.toMat(toSink, Keep.right())); }
public AkkaHubProxy(ActorMaterializer mat) { this.mat = mat; // Obtain a Sink and Source which will publish and receive from the "bus" respectively. Pair<Sink<Object, NotUsed>, Source<Object, NotUsed>> sinkAndSource = MergeHub.of(Object.class, 16) .toMat(BroadcastHub.of(Object.class, 256), Keep.both()) .run(mat); Sink<Object, NotUsed> sink = sinkAndSource.first(); source = sinkAndSource.second().takeWhile((Predicate<Object>) o -> o != Done.getInstance()); //source.runWith(Sink.ignore(), mat); busFlow = Flow.fromSinkAndSource(sink, source) .joinMat(KillSwitches.singleBidi(), Keep.right()); }
private MqttPublisherActor(final MqttConnectionFactory factory, final ActorRef mqttClientActor, final boolean dryRun) { this.mqttClientActor = mqttClientActor; this.dryRun = dryRun; final Sink<MqttMessage, CompletionStage<Done>> mqttSink = factory.newSink(); final Pair<ActorRef, CompletionStage<Done>> materializedValues = Source.<MqttMessage>actorRef(100, OverflowStrategy.dropHead()) .map(this::countPublishedMqttMessage) .toMat(mqttSink, Keep.both()) .run(ActorMaterializer.create(getContext())); materializedValues.second().handle(this::reportReadiness); sourceActor = materializedValues.first(); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); }
private MqttPublisherActor(final MqttConnectionFactory factory, final ActorRef mqttClientActor, final boolean dryRun) { this.mqttClientActor = mqttClientActor; this.dryRun = dryRun; final Sink<MqttMessage, CompletionStage<Done>> mqttSink = factory.newSink(); final Pair<ActorRef, CompletionStage<Done>> materializedValues = Source.<MqttMessage>actorRef(100, OverflowStrategy.dropHead()) .map(this::countPublishedMqttMessage) .toMat(mqttSink, Keep.both()) .run(ActorMaterializer.create(getContext())); materializedValues.second().handle(this::reportReadiness); sourceActor = materializedValues.first(); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); }
public <D> Accumulator<D, A> through(Flow<D, E, ?> flow) { return new SinkAccumulator<>(flow.toMat(toSink, Keep.right())); }
public <D> Accumulator<D, A> through(Flow<D, E, ?> flow) { return new SinkAccumulator<>(flow.toMat(sink, Keep.right())); }
public <D> Accumulator<D, A> through(Flow<D, E, ?> flow) { return new SinkAccumulator<>(flow.toMat(sink, Keep.right())); }
@Override public Removable addUpstream(Source<Object, NotUsed> publisher) { UniqueKillSwitch killSwitch = publisher.viaMat(busFlow, Keep.right()) .to(Sink.ignore()) .run(mat); subscriptions.put(publisher, killSwitch); return () -> AkkaHubProxy.this.removeUpstream(publisher); }
@Override public void emit(Object event) { Source.single(event).viaMat(busFlow, Keep.right()) .to(Sink.ignore()) .run(mat); }