private ListenableFuture startRefreshAttempt()

in alloydb-jdbc-connector/src/main/java/com/google/cloud/alloydb/Refresher.java [199:220]


  private ListenableFuture<ConnectionInfo> startRefreshAttempt() {
    // As soon as we begin submitting refresh attempts to the executor, mark a refresh
    // as "in-progress" so that subsequent forceRefresh() calls balk until this one completes.
    synchronized (connectionInfoGuard) {
      refreshRunning = true;
    }

    logger.debug(String.format("[%s] Refresh Operation: Acquiring rate limiter permit.", name));
    ListenableFuture<?> delay = rateLimiter.acquireAsync(executor);
    delay.addListener(
        () ->
            logger.debug(
                String.format("[%s] Refresh Operation: Rate limiter permit acquired.", name)),
        executor);

    // Once rate limiter is done, attempt to getInstanceData.
    ListenableFuture<ConnectionInfo> f =
        Futures.whenAllComplete(delay).callAsync(refreshOperation::get, executor);

    // Finally, reschedule refresh after getInstanceData is complete.
    return Futures.whenAllComplete(f).callAsync(() -> handleRefreshResult(f), executor);
  }