in pekko-sample-cluster-client-grpc-java/src/main/java/sample/cluster/client/grpc/ClusterClientReceptionist.java [59:84]
public ClusterClientReceptionist(ExtendedActorSystem system) {
this.system = system;
this.log = Logging.getLogger(system, getClass());
this.settings = ClusterReceptionistSettings.create(system);
this.role = settings.role;
log.info("Starting ClusterClientReceptionist gRPC server at {}", settings.hostPort);
ClusterClientSerialization serialization = new ClusterClientSerialization(system);
Materializer materializer = SystemMaterializer.get(system).materializer();
Function<HttpRequest, CompletionStage<HttpResponse>> service = ClusterClientReceptionistServiceHandlerFactory.create(
new ClusterClientReceptionistGrpcImpl(settings, pubSubMediator(), serialization, materializer, log),
system);
CompletionStage<ServerBinding> bound =
Http.get(system)
.newServerAt(settings.hostPort.hostname, settings.hostPort.port)
.bind(service)
.whenComplete((result, exc) -> {
if (exc == null)
log.info("ClusterClientReceptionist gRPC server stopped successfully");
else
log.info("ClusterClientReceptionist gRPC server stopped after failure: {}", exc);
});
}