/** * <pre> * One empty request followed by one empty response. * </pre> */ public void emptyCall(io.vertx.example.grpc.EmptyProtos.Empty request, io.vertx.core.Future<io.vertx.example.grpc.EmptyProtos.Empty> response) { asyncUnimplementedUnaryCall(getEmptyCallMethod(), EmptyPingPongServiceGrpc.toObserver(response.completer())); }
/** * <pre> * A simple RPC. * Obtains the feature at a given position. * A feature with an empty name is returned if there's no feature at the given * position. * </pre> */ public void getFeature(io.grpc.examples.routeguide.Point request, io.vertx.core.Future<io.grpc.examples.routeguide.Feature> response) { asyncUnimplementedUnaryCall(getGetFeatureMethod(), RouteGuideGrpc.toObserver(response.completer())); }
/** * <pre> * One request followed by one response. * </pre> */ public void unaryCall(io.vertx.example.grpc.Messages.SimpleRequest request, io.vertx.core.Future<io.vertx.example.grpc.Messages.SimpleResponse> response) { asyncUnimplementedUnaryCall(getUnaryCallMethod(), PingPongServiceGrpc.toObserver(response.completer())); }
/** * <pre> * Sends a greeting * </pre> */ public void sayHello(io.grpc.examples.helloworld.HelloRequest request, io.vertx.core.Future<io.grpc.examples.helloworld.HelloReply> response) { asyncUnimplementedUnaryCall(getSayHelloMethod(), GreeterGrpc.toObserver(response.completer())); }
/** * <pre> * A client-to-server streaming RPC. * Accepts a stream of Points on a route being traversed, returning a * RouteSummary when traversal is completed. * </pre> */ public void recordRoute(io.vertx.grpc.GrpcReadStream<io.grpc.examples.routeguide.Point> request, io.vertx.core.Future<io.grpc.examples.routeguide.RouteSummary> response) { request.setReadObserver(asyncUnimplementedStreamingCall(getRecordRouteMethod(), RouteGuideGrpc.toObserver(response.completer()))); }
@Override public void start(Future<Void> future) { startTransactionService(); startHttpServer().setHandler(future.completer()); }
/** * <pre> * A sequence of requests followed by one response (streamed upload). * The server returns the aggregated size of client payload as the result. * </pre> */ public void streamingInputCall(io.vertx.grpc.GrpcReadStream<io.vertx.example.grpc.Messages.StreamingInputCallRequest> request, io.vertx.core.Future<io.vertx.example.grpc.Messages.StreamingInputCallResponse> response) { request.setReadObserver(asyncUnimplementedStreamingCall(getStreamingInputCallMethod(), ProducerServiceGrpc.toObserver(response.completer()))); }
@Override public void start() throws Exception { JsonObject config = config(); id = config.getInteger("id"); numAddresses = config.getInteger("addressesCount"); List<Future> registrationFutures = new ArrayList<>(numAddresses); for (int i = 0; i < numAddresses; i++) { Future<Void> registrationFuture = Future.future(); registrationFutures.add(registrationFuture); vertx.eventBus().consumer(createAddress(id, i), msg -> msg.reply("pong")).completionHandler(registrationFuture.completer()); } Future<Void> registrationFuture = Future.future(); registrationFutures.add(registrationFuture); vertx.eventBus().consumer("ping", this::ping).completionHandler(registrationFuture.completer()); CompositeFuture.all(registrationFutures).setHandler(ar -> { if (ar.succeeded()) { vertx.eventBus().send("control", "start"); } }); }
@Override public void handle(Future<Void> fut) { TopicOperator.this.reconcileOnTopicChange(topicName, null, fut.completer()); } };
@Override public void start() throws Exception { JsonObject config = config(); id = config.getInteger("id"); numAddresses = config.getInteger("addressesCount"); List<Future> registrationFutures = new ArrayList<>(numAddresses); for (int i = 0; i < numAddresses; i++) { Future<Void> registrationFuture = Future.future(); registrationFutures.add(registrationFuture); vertx.eventBus().consumer(createAddress(id, i), msg -> msg.reply("pong")).completionHandler(registrationFuture.completer()); } Future<Void> registrationFuture = Future.future(); registrationFutures.add(registrationFuture); vertx.eventBus().consumer("ping", this::ping).completionHandler(registrationFuture.completer()); CompositeFuture.all(registrationFutures).setHandler(ar -> { if (ar.succeeded()) { vertx.eventBus().send("control", "start"); } }); }
@Override public void handle(Future<Void> fut) { kafka.topicMetadata(topicName, metadataResult -> { if (metadataResult.succeeded()) { Topic topic = TopicSerialization.fromTopicMetadata(metadataResult.result()); TopicOperator.this.reconcileOnTopicChange(topicName, topic, fut.completer()); } else { fut.fail(metadataResult.cause()); } }); } };
protected Future<SQLConnection> getConnection() { Future<SQLConnection> future = Future.future(); client.getConnection(future.completer()); return future; }
/** * Get all REST endpoints from the service discovery infrastructure. * * @return async result */ private Future<List<Record>> getAllEndpoints() { Future<List<Record>> future = Future.future(); discovery.getRecords(record -> record.getType().equals(HttpEndpoint.TYPE), future.completer()); return future; }
@Override public Future<Integer> decrease(String productId, int decrease) { Future<Long> future = Future.future(); client.decrby(PREFIX + productId, decrease, future.completer()); return future.map(Long::intValue); }
private Future<Void> deployRestService(ProductService service) { Future<String> future = Future.future(); vertx.deployVerticle(new RestProductAPIVerticle(service), new DeploymentOptions().setConfig(config()), future.completer()); return future.map(r -> null); }
private Future<Void> prepareDispatcher() { Future<String> future = Future.future(); vertx.deployVerticle(new RawOrderDispatcher(orderService), new DeploymentOptions().setConfig(config()), future.completer()); return future.map(r -> null); }
private Future<Void> deployRestVerticle() { Future<String> future = Future.future(); vertx.deployVerticle(new RestShoppingAPIVerticle(shoppingCartService, checkoutService), new DeploymentOptions().setConfig(config()), future.completer()); return future.map(r -> null); }
private Future<Void> initProductDatabase(ProductService service) { Future<Void> initFuture = Future.future(); service.initializePersistence(initFuture.completer()); return initFuture.map(v -> { ExampleHelper.initData(vertx, config()); return null; }); }
@Override public void start(Future<Void> future) throws Exception { super.start(); // create the service instance accountService = new JdbcAccountServiceImpl(vertx, config()); // register the service proxy on event bus ProxyHelper.registerService(AccountService.class, vertx, accountService, SERVICE_ADDRESS); // publish the service and REST endpoint in the discovery infrastructure publishEventBusService(SERVICE_NAME, SERVICE_ADDRESS, AccountService.class) .compose(servicePublished -> deployRestVerticle()) .setHandler(future.completer()); }
@Override public void start(Future<Void> future) throws Exception { super.start(); this.orderService = new OrderServiceImpl(vertx, config()); ProxyHelper.registerService(OrderService.class, vertx, orderService, SERVICE_ADDRESS); initOrderDatabase() .compose(databaseOkay -> publishEventBusService(SERVICE_NAME, SERVICE_ADDRESS, OrderService.class)) .compose(servicePublished -> prepareDispatcher()) .compose(dispatcherPrepared -> deployRestVerticle()) .setHandler(future.completer()); }