docs: private boolean completeResponse(OperationResponse response, Runnable callback) {
      // If the response is null, that indicates an exception occurred. The best we can do is complete
      // the response in sequential order.
      if (response == null) {
        log.trace("Completing failed request");
        callback.run();
        return true;
      }
  
      // If the response's event index is greater than the current event index, that indicates that events that were
      // published prior to the response have not yet been completed. Attempt to complete pending events.
      if (response.eventIndex() > eventIndex) {
        // For each pending event with an eventIndex less than or equal to the response eventIndex, complete the event.
        // This is safe since we know that sequenced responses should see sequential order of events.
        EventCallback eventCallback = eventCallbacks.peek();
        while (eventCallback != null && eventCallback.request.eventIndex() <= response.eventIndex()) {
          eventCallbacks.remove();
          log.trace("Completing event {}", eventCallback.request);
          eventCallback.run();
          eventIndex = eventCallback.request.eventIndex();
          eventCallback = eventCallbacks.peek();
        }
      }
  
      // If after completing pending events the eventIndex is greater than or equal to the response's eventIndex, complete the response.
      // Note that the event protocol initializes the eventIndex to the session ID.
      if (response.eventIndex() <= eventIndex || (eventIndex == 0 && response.eventIndex() == state.getSessionId().id())) {
        log.trace("Completing response {}", response);
        callback.run();
        return true;
      } else {
        return false;
      }
    }