#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#[derive(Clone, Debug)]
pub struct QuotaController {
inner: std::sync::Arc<dyn super::stub::dynamic::QuotaController>,
}
impl QuotaController {
pub fn builder() -> super::builder::quota_controller::ClientBuilder {
crate::new_client_builder(super::builder::quota_controller::client::Factory)
}
pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
where
T: super::stub::QuotaController + 'static,
{
Self { inner: stub.into() }
}
pub(crate) async fn new(
config: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<Self> {
let inner = Self::build_inner(config).await?;
Ok(Self { inner })
}
async fn build_inner(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::QuotaController>> {
if gaxi::options::tracing_enabled(&conf) {
return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
}
Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
}
async fn build_transport(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::QuotaController> {
super::transport::QuotaController::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::QuotaController> {
Self::build_transport(conf)
.await
.map(super::tracing::QuotaController::new)
}
pub fn allocate_quota(&self) -> super::builder::quota_controller::AllocateQuota {
super::builder::quota_controller::AllocateQuota::new(self.inner.clone())
}
}
#[derive(Clone, Debug)]
pub struct ServiceController {
inner: std::sync::Arc<dyn super::stub::dynamic::ServiceController>,
}
impl ServiceController {
pub fn builder() -> super::builder::service_controller::ClientBuilder {
crate::new_client_builder(super::builder::service_controller::client::Factory)
}
pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
where
T: super::stub::ServiceController + 'static,
{
Self { inner: stub.into() }
}
pub(crate) async fn new(
config: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<Self> {
let inner = Self::build_inner(config).await?;
Ok(Self { inner })
}
async fn build_inner(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ServiceController>>
{
if gaxi::options::tracing_enabled(&conf) {
return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
}
Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
}
async fn build_transport(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::ServiceController> {
super::transport::ServiceController::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::ServiceController> {
Self::build_transport(conf)
.await
.map(super::tracing::ServiceController::new)
}
pub fn check(&self) -> super::builder::service_controller::Check {
super::builder::service_controller::Check::new(self.inner.clone())
}
pub fn report(&self) -> super::builder::service_controller::Report {
super::builder::service_controller::Report::new(self.inner.clone())
}
}