Repository: envoyproxy/envoy
File: envoy/tcp/upstream.h (C/C++)

Code before:
   * @return returns true if the disable is performed, false otherwise
   *         (e.g. if the connection is closed)
   */
  virtual bool readDisable(bool disable) PURE;

  /**
   * Encodes data upstream.
   * @param data supplies the data to encode. The data may be moved by the encoder.
   * @param end_stream supplies whether this is the last data to encode.
   */
  virtual void encodeData(Buffer::Instance& data, bool end_stream) PURE;

  /**
   * Adds a callback to be called when the data is sent to the kernel.
   * @param cb supplies the callback to be called
   */
  virtual void addBytesSentCallback(Network::Connection::BytesSentCb cb) PURE;

  /**
   * Called when an event is received on the downstream connection
   * @param event supplies the event which occurred.
   * @return the underlying ConnectionData if the event is not "Connected" and draining
             is supported for this upstream.
   */
  virtual Tcp::ConnectionPool::ConnectionData*
  onDownstreamEvent(Network::ConnectionEvent event, absl::string_view close_details = "") PURE;

  /* Called to convert underlying transport socket from non-secure mode
   * to secure mode. Implemented only by start_tls transport socket.
   */
  virtual bool startUpstreamSecureTransport() PURE;

  /**
   * Called when upstream starttls socket is converted to tls and upstream ssl info
   * needs to be set in the connection's stream_info.
   * @return the const SSL connection data of upstream.
   */
  virtual Ssl::ConnectionInfoConstSharedPtr getUpstreamConnectionSslInfo() PURE;

  /**
   * Called when upstream connection is closed.
   * @return the detected close type from socket.
   */
  virtual StreamInfo::DetectedCloseType detectedCloseType() const PURE;

  /**
   * @return the failure reason of the local close.
   */
  virtual absl::string_view localCloseReason() const { return ""; }
};


Review comment (suggestion):
still prefer `details` here, and please update the method doc above.

Code after:
   * @return returns true if the disable is performed, false otherwise
   *         (e.g. if the connection is closed)
   */
  virtual bool readDisable(bool disable) PURE;

  /**
   * Encodes data upstream.
   * @param data supplies the data to encode. The data may be moved by the encoder.
   * @param end_stream supplies whether this is the last data to encode.
   */
  virtual void encodeData(Buffer::Instance& data, bool end_stream) PURE;

  /**
   * Adds a callback to be called when the data is sent to the kernel.
   * @param cb supplies the callback to be called
   */
  virtual void addBytesSentCallback(Network::Connection::BytesSentCb cb) PURE;

  /**
   * Called when an event is received on the downstream connection
   * @param event supplies the event which occurred.
   * @param details supplies the details of the event, e.g. the local close reason.
   * @return the underlying ConnectionData if the event is not "Connected" and draining
             is supported for this upstream.
   */
  virtual Tcp::ConnectionPool::ConnectionData*
  onDownstreamEvent(Network::ConnectionEvent event, absl::string_view details = "") PURE;

  /* Called to convert underlying transport socket from non-secure mode
   * to secure mode. Implemented only by start_tls transport socket.
   */
  virtual bool startUpstreamSecureTransport() PURE;

  /**
   * Called when upstream starttls socket is converted to tls and upstream ssl info
   * needs to be set in the connection's stream_info.
   * @return the const SSL connection data of upstream.
   */
  virtual Ssl::ConnectionInfoConstSharedPtr getUpstreamConnectionSslInfo() PURE;

  /**
   * Called when upstream connection is closed.
   * @return the detected close type from socket.
   */
  virtual StreamInfo::DetectedCloseType detectedCloseType() const PURE;

  /**
   * @return the failure reason of the local close.
   */
  virtual absl::string_view localCloseReason() const { return ""; }
};