code: public static void retryOrCancel(final CoreEnvironment environment, final CouchbaseRequest request,
          final EventSink<ResponseEvent> responseBuffer) {
          if (!request.isActive()) {
              return;
          }
  
          if (environment.retryStrategy().shouldRetry(request, environment)) {
              retry(request, responseBuffer);
          } else {
              request.observable().onError(new RequestCancelledException("Could not dispatch request, cancelling "
                  + "instead of retrying."));
          }
      }
docs: Either retry or cancel a request, based on the strategy used.
  
  @param environment the core environment for context.
  @param request the request to either retry or cancel.
  @param responseBuffer the response buffer where to maybe retry on.