use crate::Result;
#[derive(Clone, Debug)]
pub struct DestinationService<T>
where
T: super::stub::DestinationService + std::fmt::Debug + Send + Sync,
{
inner: T,
duration: gaxi::observability::DurationMetric,
}
impl<T> DestinationService<T>
where
T: super::stub::DestinationService + 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::DestinationService for DestinationService<T>
where
T: super::stub::DestinationService + std::fmt::Debug + Send + Sync,
{
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn search_destinations(
&self,
req: crate::model::SearchDestinationsRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::SearchDestinationsResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::DestinationService::search_destinations",
self.inner.search_destinations(req, options));
pending.await
}
}
#[derive(Clone, Debug)]
pub struct GeocodeService<T>
where
T: super::stub::GeocodeService + std::fmt::Debug + Send + Sync,
{
inner: T,
duration: gaxi::observability::DurationMetric,
}
impl<T> GeocodeService<T>
where
T: super::stub::GeocodeService + 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::GeocodeService for GeocodeService<T>
where
T: super::stub::GeocodeService + std::fmt::Debug + Send + Sync,
{
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn geocode_address(
&self,
req: crate::model::GeocodeAddressRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::GeocodeAddressResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::GeocodeService::geocode_address",
self.inner.geocode_address(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn geocode_location(
&self,
req: crate::model::GeocodeLocationRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::GeocodeLocationResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::GeocodeService::geocode_location",
self.inner.geocode_location(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn geocode_place(
&self,
req: crate::model::GeocodePlaceRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::GeocodeResult>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::GeocodeService::geocode_place",
self.inner.geocode_place(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 = "geocoding-backend";
info.client_version = VERSION;
info.client_artifact = NAME;
info.default_host = "geocoding-backend";
info
});
}