protected <T extends Request, U extends Response> CompletableFuture<U> forward(T request) {
    CompletableFuture<U> future = new CompletableFuture<>();
    context.getConnections().getConnection(context.getLeader().serverAddress()).whenComplete((connection, connectError) -> {
      if (connectError == null) {
        connection.<T, U>sendAndReceive(request).whenComplete((response, responseError) -> {
          if (responseError == null) {
            future.complete(response);
          } else {
            future.completeExceptionally(responseError);
          }
        });
      } else {
        future.completeExceptionally(connectError);
      }
    });
    return future;
  }
protected < T extends Request , U extends Response > CompletableFuture < U > forward ( T request ) { CompletableFuture < U > future = new CompletableFuture < > ( ) ; context . getConnections ( ) . getConnection ( context . getLeader ( ) . serverAddress ( ) ) . whenComplete ( ( connection , connectError ) -> { if ( connectError == null ) { connection . < T , U > sendAndReceive ( request ) . whenComplete ( ( response , responseError ) -> { if ( responseError == null ) { future . complete ( response ) ; } else { future . completeExceptionally ( responseError ) ; } } ) ; } else { future . completeExceptionally ( connectError ) ; } } ) ; return future ; }
Forwards the given request to the leader if possible.