void GrpcHealthCheckerImpl::GrpcActiveHealthCheckSession::onRpcComplete(
    Grpc::Status::GrpcStatus grpc_status, const std::string& grpc_message, bool end_stream) {
  logHealthCheckStatus(grpc_status, grpc_message);
  if (isHealthCheckSucceeded(grpc_status)) {
    handleSuccess(false);
  } else {
    handleFailure(envoy::data::core::v3::ACTIVE);
  }

  // Read the value as we may call resetState() and clear it.
  const bool goaway = received_no_error_goaway_;

  // |end_stream| will be false if we decided to stop healthcheck before HTTP stream has ended -
  // invalid gRPC payload, unexpected message stream or wrong content-type.
  if (end_stream) {
    resetState();
  } else {
    // request_encoder_ can already be destroyed if the host was removed during the failure callback
    // above.
    if (request_encoder_ != nullptr) {
      // resetState() will be called by onResetStream().
      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 && (!parent_.reuse_connection_ || goaway)) {
    client_->close();
  }
}
void GrpcHealthCheckerImpl::GrpcActiveHealthCheckSession::onRpcComplete(
    Grpc::Status::GrpcStatus grpc_status, const std::string& grpc_message, bool end_stream) {
  logHealthCheckStatus(grpc_status, grpc_message);
  if (isHealthCheckSucceeded(grpc_status)) {
    handleSuccess(false);
  } else {
    handleFailure(envoy::data::core::v3::ACTIVE);
  }

   
  const bool goaway = received_no_error_goaway_;

   
   
  if (end_stream) {
    resetState();
  } else {
     
     
    if (request_encoder_ != nullptr) {
       
      expect_reset_ = true;
      request_encoder_->getStream().resetStream(Http::StreamResetReason::LocalReset);
    }
  }

   
  if (client_ != nullptr && (!parent_.reuse_connection_ || goaway)) {
    client_->close();
  }
}