void GrpcHealthCheckerImpl::GrpcActiveHealthCheckSession::onGoAway(
    Http::GoAwayErrorCode error_code) {
  ENVOY_CONN_LOG(debug, "connection going away health_flags={}", *client_,
                 HostUtility::healthFlagsToString(*host_));
  // If we have an active health check probe and receive a GOAWAY indicating
  // graceful shutdown, allow the probe to complete before closing the connection.
  // The connection will be closed when the active check completes or another
  // terminal condition occurs, such as a timeout or stream reset.
  if (request_encoder_ && error_code == Http::GoAwayErrorCode::NoError) {
    received_no_error_goaway_ = true;
    return;
  }

  // Even if we have active health check probe, fail it on GOAWAY and schedule new one.
  if (request_encoder_) {
    handleFailure(envoy::data::core::v3::NETWORK);
    // request_encoder_ can already be destroyed if the host was removed during the failure callback
    // above.
    if (request_encoder_ != nullptr) {
      expect_reset_ = true;
      request_encoder_->getStream().resetStream(Http::StreamResetReason::LocalReset);
    }
  }
  // client_ can already be destroyed if the host was removed during the failure callback above.
  if (client_ != nullptr) {
    client_->close();
  }
}
void GrpcHealthCheckerImpl::GrpcActiveHealthCheckSession::onGoAway(
    Http::GoAwayErrorCode error_code) {
  ENVOY_CONN_LOG(debug, "connection going away health_flags={}", *client_,
                 HostUtility::healthFlagsToString(*host_));
   
   
   
   
  if (request_encoder_ && error_code == Http::GoAwayErrorCode::NoError) {
    received_no_error_goaway_ = true;
    return;
  }

   
  if (request_encoder_) {
    handleFailure(envoy::data::core::v3::NETWORK);
     
     
    if (request_encoder_ != nullptr) {
      expect_reset_ = true;
      request_encoder_->getStream().resetStream(Http::StreamResetReason::LocalReset);
    }
  }
   
  if (client_ != nullptr) {
    client_->close();
  }
}