Skip to main content

ConnectionConfig

Struct ConnectionConfig 

Source
pub struct ConnectionConfig {
Show 13 fields pub provider: String, pub startup_required: bool, pub request_timeout_ms: u64, pub poll_interval_ms: u64, pub idle_timeout_ms: u64, pub snapshot: SnapshotPolicy, pub retry: RetryPolicy, pub nacos: Option<Value>, pub consul: Option<Value>, pub kubernetes: Option<Value>, pub static_config: Option<StaticConfig>, pub dns: Option<DnsConfig>, pub rest: Option<RestPolicy>,
}
Expand description

单个 qualifier 的后端配置;provider 必须与唯一的后端配置块一致。

Fields§

§provider: String

后端类型或实例,决定该连接支持的发现及注册能力。

§startup_required: bool

是否要求启动阶段确认成功;失败时阻止宿主完成启动。

§request_timeout_ms: u64

一次请求的最大耗时,单位为毫秒。

§poll_interval_ms: u64

后台轮询间隔,单位为毫秒,必须留出请求和证据时效预算。

§idle_timeout_ms: u64

无人使用的服务观察保留时长,单位为毫秒。

§snapshot: SnapshotPolicy

共享发现证据的年龄上限与异常宽限。

§retry: RetryPolicy

连接准备失败时的重试退避预算。

§nacos: Option<Value>

Nacos 专用配置,只有 Nacos 后端可以使用。

§consul: Option<Value>

Consul 专用配置,只有 Consul 后端可以使用。

§kubernetes: Option<Value>

Kubernetes 只读发现配置,不授予 Service 或 EndpointSlice 写入权。

§static_config: Option<StaticConfig>

静态实例映射;配置文件中的键为 static。

§dns: Option<DnsConfig>

DNS 服务映射,不支持服务注册。

§rest: Option<RestPolicy>

该连接的 REST 调用策略,与其他 qualifier 的调用预算隔离。

Implementations§

Source§

impl ConnectionConfig

Source

pub fn has_service(&self, service: &str) -> bool

业务作用:在网络准备之前核对宿主引用是否属于该连接的显式服务目录。

参数说明:

  • service:是本地服务别名,不能替代后端服务名或跨连接查询。

返回:静态、DNS 或已配置 provider 服务表包含该精确别名时为 true。

Source

pub fn policy(&self) -> ConnectionPolicy

业务作用:把公开配置转换为 owner 的冻结时效预算。

参数说明:无。

返回:不依赖具体传输默认值的公共策略。

Source

pub fn validate(&self) -> Result<()>

业务作用:拒绝同时填写多个 provider 块或未编入的运行时能力。

参数说明:无。

返回:恰好一个匹配 provider 块通过。

Trait Implementations§

Source§

impl Clone for ConnectionConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ConnectionConfig

Source§

fn default() -> Self

业务作用:默认连接必须准备成功,但没有指定 provider 时不猜测后端。

参数说明:无。

返回:有限请求和观察预算的候选配置。

Source§

impl<'de> Deserialize<'de> for ConnectionConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ConnectionConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.