use mz_proto::{ProtoType, RustType, TryFromProtoError};
use proptest_derive::Arbitrary;
use serde::{Deserialize, Serialize};
use std::time::Duration;
include!(concat!(env!("OUT_DIR"), "/mz_service.params.rs"));
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq, Arbitrary)]
pub struct GrpcClientParameters {
pub connect_timeout: Option<Duration>,
pub http2_keep_alive_interval: Option<Duration>,
pub http2_keep_alive_timeout: Option<Duration>,
}
impl GrpcClientParameters {
pub fn update(&mut self, other: Self) {
let Self {
connect_timeout,
http2_keep_alive_interval,
http2_keep_alive_timeout,
} = self;
let Self {
connect_timeout: other_connect_timeout,
http2_keep_alive_interval: other_http2_keep_alive_interval,
http2_keep_alive_timeout: other_http2_keep_alive_timeout,
} = other;
if let Some(v) = other_connect_timeout {
*connect_timeout = Some(v);
}
if let Some(v) = other_http2_keep_alive_interval {
*http2_keep_alive_interval = Some(v);
}
if let Some(v) = other_http2_keep_alive_timeout {
*http2_keep_alive_timeout = Some(v);
}
}
pub fn all_unset(&self) -> bool {
*self == Self::default()
}
}
impl RustType<ProtoGrpcClientParameters> for GrpcClientParameters {
fn into_proto(&self) -> ProtoGrpcClientParameters {
ProtoGrpcClientParameters {
connect_timeout: self.connect_timeout.into_proto(),
http2_keep_alive_interval: self.http2_keep_alive_interval.into_proto(),
http2_keep_alive_timeout: self.http2_keep_alive_timeout.into_proto(),
}
}
fn from_proto(proto: ProtoGrpcClientParameters) -> Result<Self, TryFromProtoError> {
Ok(Self {
connect_timeout: proto.connect_timeout.into_rust()?,
http2_keep_alive_interval: proto.http2_keep_alive_interval.into_rust()?,
http2_keep_alive_timeout: proto.http2_keep_alive_timeout.into_rust()?,
})
}
}