use crate::Result;
#[derive(Clone, Debug)]
pub struct Weather<T>
where
T: super::stub::Weather + std::fmt::Debug + Send + Sync,
{
inner: T,
duration: gaxi::observability::DurationMetric,
}
impl<T> Weather<T>
where
T: super::stub::Weather + 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::Weather for Weather<T>
where
T: super::stub::Weather + std::fmt::Debug + Send + Sync,
{
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn lookup_current_conditions(
&self,
req: crate::model::LookupCurrentConditionsRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::LookupCurrentConditionsResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::Weather::lookup_current_conditions",
self.inner.lookup_current_conditions(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn lookup_forecast_hours(
&self,
req: crate::model::LookupForecastHoursRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::LookupForecastHoursResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::Weather::lookup_forecast_hours",
self.inner.lookup_forecast_hours(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn lookup_forecast_days(
&self,
req: crate::model::LookupForecastDaysRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::LookupForecastDaysResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::Weather::lookup_forecast_days",
self.inner.lookup_forecast_days(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn lookup_history_hours(
&self,
req: crate::model::LookupHistoryHoursRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::LookupHistoryHoursResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::Weather::lookup_history_hours",
self.inner.lookup_history_hours(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn lookup_public_alerts(
&self,
req: crate::model::LookupPublicAlertsRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::LookupPublicAlertsResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::Weather::lookup_public_alerts",
self.inner.lookup_public_alerts(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn lookup_forecast_minutes(
&self,
req: crate::model::LookupForecastMinutesRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::LookupForecastMinutesResponse>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::Weather::lookup_forecast_minutes",
self.inner.lookup_forecast_minutes(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 = "weather";
info.client_version = VERSION;
info.client_artifact = NAME;
info.default_host = "weather";
info
});
}