本文整理了Java中akka.stream.javadsl.Source.to()
方法的一些代码示例,展示了Source.to()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Source.to()
方法的具体详情如下:
包路径:akka.stream.javadsl.Source
类名称:Source
方法名:to
暂无
代码示例来源:origin: apptik/RHub
@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);
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-akka
private GraphActor(final BiFunction<ActorContext,
DiagnosticLoggingAdapter, Graph<SinkShape<WithSender>, NotUsed>> graphCreator) {
materializer = ActorMaterializer.create(getContext());
messageHandler = MergeHub.of(WithSender.class).to(graphCreator.apply(getContext(), log)).run(materializer);
}
代码示例来源:origin: eclipse/ditto
private GraphActor(final BiFunction<ActorContext,
DiagnosticLoggingAdapter, Graph<SinkShape<WithSender>, NotUsed>> graphCreator) {
materializer = ActorMaterializer.create(getContext());
messageHandler = MergeHub.of(WithSender.class).to(graphCreator.apply(getContext(), log)).run(materializer);
}
代码示例来源:origin: eclipse/ditto
private GraphActor(final Function<ActorContext, Graph<SinkShape<WithSender>, NotUsed>> graphCreator) {
materializer = ActorMaterializer.create(getContext());
messageHandler = MergeHub.of(WithSender.class).to(graphCreator.apply(getContext())).run(materializer);
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-akka
private GraphActor(final Function<ActorContext, Graph<SinkShape<WithSender>, NotUsed>> graphCreator) {
materializer = ActorMaterializer.create(getContext());
messageHandler = MergeHub.of(WithSender.class).to(graphCreator.apply(getContext())).run(materializer);
}
代码示例来源:origin: apptik/RHub
@Override
public void emit(Object event) {
Source.single(event).viaMat(busFlow, Keep.right())
.to(Sink.ignore())
.run(mat);
}
代码示例来源:origin: eclipse/ditto
private Route handleDevOpsPerRequest(final RequestContext ctx,
final Source<ByteString, ?> payloadSource,
final Function<String, DevOpsCommand> requestJsonToCommandFunction) {
final CompletableFuture<HttpResponse> httpResponseFuture = new CompletableFuture<>();
payloadSource
.fold(ByteString.empty(), ByteString::concat)
.map(ByteString::utf8String)
.map(requestJsonToCommandFunction)
.to(Sink.actorRef(createHttpPerRequestActor(ctx, httpResponseFuture),
HttpRequestActor.COMPLETE_MESSAGE))
.run(materializer);
return completeWithFuture(httpResponseFuture);
}
代码示例来源:origin: eclipse/ditto
private Route handleMessage(final RequestContext ctx, final Source<ByteString, Object> payloadSource,
final Function<ByteBuffer, MessageCommand<?, ?>> requestPayloadToCommandFunction) {
final CompletableFuture<HttpResponse> httpResponseFuture = new CompletableFuture<>();
payloadSource.fold(ByteString.empty(), ByteString::concat)
.map(ByteString::toArray)
.map(ByteBuffer::wrap)
.map(requestPayloadToCommandFunction)
.to(Sink.actorRef(createHttpPerRequestActor(ctx, httpResponseFuture),
HttpRequestActor.COMPLETE_MESSAGE))
.run(materializer);
return completeWithFuture(preprocessResponse(httpResponseFuture));
}
代码示例来源:origin: eclipse/ditto
private Route handleSudoCountThingsPerRequest(final RequestContext ctx, final SudoCountThings command) {
final CompletableFuture<HttpResponse> httpResponseFuture = new CompletableFuture<>();
Source.single(command)
.to(Sink.actorRef(createHttpPerRequestActor(ctx, httpResponseFuture),
HttpRequestActor.COMPLETE_MESSAGE))
.run(materializer);
final CompletionStage<HttpResponse> allThingsCountHttpResponse = Source.fromCompletionStage(httpResponseFuture)
.flatMapConcat(httpResponse -> httpResponse.entity().getDataBytes())
.fold(ByteString.empty(), ByteString::concat)
.map(ByteString::utf8String)
.map(Integer::valueOf)
.map(count -> JsonObject.newBuilder().set("allThingsCount", count).build())
.map(jsonObject -> HttpResponse.create()
.withEntity(ContentTypes.APPLICATION_JSON, ByteString.fromString(jsonObject.toString()))
.withStatus(HttpStatusCode.OK.toInt()))
.runWith(Sink.head(), materializer);
return completeWithFuture(allThingsCountHttpResponse);
}
代码示例来源:origin: eclipse/ditto
.build();
})
.to(Sink.actorRef(createHttpPerRequestActor(ctx, httpResponseFuture),
HttpRequestActor.COMPLETE_MESSAGE))
.run(materializer);
内容来源于网络,如有侵权,请联系作者删除!