use crate::Result;
#[derive(Clone, Debug)]
pub struct DeveloperKnowledge<T>
where
T: super::stub::DeveloperKnowledge + std::fmt::Debug + Send + Sync,
{
inner: T,
duration: gaxi::observability::DurationMetric,
}
impl<T> DeveloperKnowledge<T>
where
T: super::stub::DeveloperKnowledge + std::fmt::Debug + Send + Sync,
{
pub fn new(inner: T) -> Self {
Self {
inner,
duration: gaxi::observability::DurationMetric::new(&info::INSTRUMENTATION_CLIENT_INFO),
}
}
}
impl<T> super::stub::DeveloperKnowledge for DeveloperKnowledge<T>
where
T: super::stub::DeveloperKnowledge + std::fmt::Debug + Send + Sync,
{
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn search_document_chunks(
&self,
req: crate::model::SearchDocumentChunksRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::SearchDocumentChunksResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::DeveloperKnowledge::search_document_chunks",
self.inner.search_document_chunks(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn get_document(
&self,
req: crate::model::GetDocumentRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::Document>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::DeveloperKnowledge::get_document",
self.inner.get_document(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn batch_get_documents(
&self,
req: crate::model::BatchGetDocumentsRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::BatchGetDocumentsResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::DeveloperKnowledge::batch_get_documents",
self.inner.batch_get_documents(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn answer_query(
&self,
req: crate::model::AnswerQueryRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::AnswerQueryResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::DeveloperKnowledge::answer_query",
self.inner.answer_query(req, options));
pending.await
}
}
pub(crate) mod info {
const NAME: &str = env!("CARGO_PKG_NAME");
const VERSION: &str = env!("CARGO_PKG_VERSION");
pub(crate) static INSTRUMENTATION_CLIENT_INFO: std::sync::LazyLock<
gaxi::options::InstrumentationClientInfo,
> = std::sync::LazyLock::new(|| {
let mut info = gaxi::options::InstrumentationClientInfo::default();
info.service_name = "developerknowledge";
info.client_version = VERSION;
info.client_artifact = NAME;
info.default_host = "developerknowledge";
info
});
}