io.vertx.core.Future.completer()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中io.vertx.core.Future.completer()方法的一些代码示例,展示了Future.completer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.completer()方法的具体详情如下:
包路径:io.vertx.core.Future
类名称:Future
方法名:completer

Future.completer介绍

暂无

代码示例

代码示例来源:origin: vert-x3/vertx-examples

/**
 * <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()));
}

代码示例来源:origin: vert-x3/vertx-examples

/**
 * <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()));
}

代码示例来源:origin: vert-x3/vertx-examples

/**
 * <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()));
}

代码示例来源:origin: vert-x3/vertx-examples

/**
 * <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()));
}

代码示例来源:origin: vert-x3/vertx-examples

/**
 * <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())));
}

代码示例来源:origin: vert-x3/vertx-examples

@Override
public void start(Future<Void> future) {
 startTransactionService();
 startHttpServer().setHandler(future.completer());
}

代码示例来源:origin: vert-x3/vertx-examples

/**
 * <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())));
}

代码示例来源:origin: eclipse-vertx/vert.x

@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");
  }
 });
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

@Override
  public void handle(Future<Void> fut) {
    TopicOperator.this.reconcileOnTopicChange(topicName, null, fut.completer());
  }
};

代码示例来源:origin: io.vertx/vertx-core

@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");
  }
 });
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

@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());
      }
    });
  }
};

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

protected Future<SQLConnection> getConnection() {
 Future<SQLConnection> future = Future.future();
 client.getConnection(future.completer());
 return future;
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

/**
 * 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;
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

@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);
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

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);
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

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);
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

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);
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

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;
 });
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

@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());
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

@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());
}

相关文章