#![allow(rustdoc::bare_urls)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::invalid_html_tags)]
#![allow(rustdoc::redundant_explicit_links)]
#[derive(Clone, Debug)]
pub struct Read {
inner: std::sync::Arc<dyn super::stub::dynamic::Read>,
}
impl Read {
pub fn builder() -> super::builder::read::ClientBuilder {
crate::new_client_builder(super::builder::read::client::Factory)
}
pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
where
T: super::stub::Read + '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::Read>> {
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::Read> {
super::transport::Read::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::Read> {
Self::build_transport(conf)
.await
.map(super::tracing::Read::new)
}
pub fn create_read_session(&self) -> super::builder::read::CreateReadSession {
super::builder::read::CreateReadSession::new(self.inner.clone())
}
pub fn read_rows(&self) -> super::builder::read::ReadRows {
super::builder::read::ReadRows::new(self.inner.clone())
}
pub fn split_read_stream(&self) -> super::builder::read::SplitReadStream {
super::builder::read::SplitReadStream::new(self.inner.clone())
}
}
#[derive(Clone, Debug)]
pub struct BigQueryWrite {
inner: std::sync::Arc<dyn super::stub::dynamic::BigQueryWrite>,
}
impl BigQueryWrite {
pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
where
T: super::stub::BigQueryWrite + '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::BigQueryWrite>> {
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::BigQueryWrite> {
super::transport::BigQueryWrite::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::BigQueryWrite> {
Self::build_transport(conf)
.await
.map(super::tracing::BigQueryWrite::new)
}
pub(crate) fn create_write_stream(&self) -> super::builder::big_query_write::CreateWriteStream {
super::builder::big_query_write::CreateWriteStream::new(self.inner.clone())
}
pub(crate) fn append_rows(&self) -> super::builder::big_query_write::AppendRows {
super::builder::big_query_write::AppendRows::new(self.inner.clone())
}
pub(crate) fn get_write_stream(&self) -> super::builder::big_query_write::GetWriteStream {
super::builder::big_query_write::GetWriteStream::new(self.inner.clone())
}
pub(crate) fn finalize_write_stream(
&self,
) -> super::builder::big_query_write::FinalizeWriteStream {
super::builder::big_query_write::FinalizeWriteStream::new(self.inner.clone())
}
pub(crate) fn batch_commit_write_streams(
&self,
) -> super::builder::big_query_write::BatchCommitWriteStreams {
super::builder::big_query_write::BatchCommitWriteStreams::new(self.inner.clone())
}
pub(crate) fn flush_rows(&self) -> super::builder::big_query_write::FlushRows {
super::builder::big_query_write::FlushRows::new(self.inner.clone())
}
}