#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#[derive(Clone, Debug)]
pub struct ProfilerService {
inner: std::sync::Arc<dyn super::stub::dynamic::ProfilerService>,
}
impl ProfilerService {
pub fn builder() -> super::builder::profiler_service::ClientBuilder {
crate::new_client_builder(super::builder::profiler_service::client::Factory)
}
pub fn from_stub<T>(stub: T) -> Self
where
T: super::stub::ProfilerService + 'static,
{
Self {
inner: std::sync::Arc::new(stub),
}
}
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::ProfilerService>> {
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::ProfilerService> {
super::transport::ProfilerService::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::ProfilerService> {
Self::build_transport(conf)
.await
.map(super::tracing::ProfilerService::new)
}
pub fn create_profile(&self) -> super::builder::profiler_service::CreateProfile {
super::builder::profiler_service::CreateProfile::new(self.inner.clone())
}
pub fn create_offline_profile(&self) -> super::builder::profiler_service::CreateOfflineProfile {
super::builder::profiler_service::CreateOfflineProfile::new(self.inner.clone())
}
pub fn update_profile(&self) -> super::builder::profiler_service::UpdateProfile {
super::builder::profiler_service::UpdateProfile::new(self.inner.clone())
}
}
#[derive(Clone, Debug)]
pub struct ExportService {
inner: std::sync::Arc<dyn super::stub::dynamic::ExportService>,
}
impl ExportService {
pub fn builder() -> super::builder::export_service::ClientBuilder {
crate::new_client_builder(super::builder::export_service::client::Factory)
}
pub fn from_stub<T>(stub: T) -> Self
where
T: super::stub::ExportService + 'static,
{
Self {
inner: std::sync::Arc::new(stub),
}
}
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::ExportService>> {
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::ExportService> {
super::transport::ExportService::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::ExportService> {
Self::build_transport(conf)
.await
.map(super::tracing::ExportService::new)
}
pub fn list_profiles(&self) -> super::builder::export_service::ListProfiles {
super::builder::export_service::ListProfiles::new(self.inner.clone())
}
}