Skip to main content

LocalProvider

Struct LocalProvider 

Source
pub struct LocalProvider { /* private fields */ }
Expand description

静态实例或 DNS 地址的只读适配器,不提供注册中心健康证据或写入能力。

Implementations§

Source§

impl LocalProvider

Source

pub fn static_services( services: BTreeMap<String, Vec<Instance>>, ) -> Result<Self>

业务作用:冻结普通服务的静态实例表,不产生自注册副作用。 参数说明:services 为服务到完整实例列表的显式映射。 返回:合法静态表对应的只读 provider。

Source

pub fn dns_services(services: BTreeMap<String, DnsService>) -> Result<Self>

业务作用:复用 A/AAAA 地址解析,只允许显式服务绑定。 参数说明:services 为服务别名与主机端口映射。 返回:只读 DNS provider,不承诺 SRV、DNS TTL 或业务健康。

Trait Implementations§

Source§

impl ManagedProvider for LocalProvider

Source§

fn capabilities(&self) -> Capabilities

业务作用:准确声明本地后端只读与证据边界。 参数说明:无。 返回:Static 或 Address 证据,永不声明远端健康。

Source§

fn prepare<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

业务作用:确认本地配置 provider 仍开放。 参数说明:无。 返回:不把 DNS 配置有效误报为远端服务健康。

Source§

fn observe<'life0, 'life1, 'async_trait>( &'life0 self, service: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<ProviderSnapshot>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

业务作用:读取完整静态表或执行一次 DNS 地址解析。 参数说明:service 是显式服务别名。 返回:完整候选或地址解析失败,不使用旧 DNS 缓存伪造新证据。

Source§

fn services<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

业务作用:只枚举显式配置服务,不执行全局目录扫描。 参数说明:无。 返回:本连接配置的服务名。

Source§

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

业务作用:禁止该本地适配器接受新观察。 参数说明:无。 返回:重复关闭幂等,没有独立后台循环。

Source§

fn change_wait_timeout(&self) -> Option<Duration>

业务作用:声明后端能否提供不占用短请求额度的变更等待。 参数说明:无。 返回:最大等待时间;通知仅触发完整重读,不构成健康证据。
Source§

fn change_wait_streams(&self) -> u32

业务作用:为一次变更等待预留实际可能并发的后端长请求额度。 参数说明:无。 返回:默认一个请求;同时观察多类资源的 provider 必须报告合计上限。
Source§

fn wait_for_change<'life0, 'life1, 'async_trait>( &'life0 self, _service: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), DiscoveryError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

业务作用:等待服务或端点变化,调用方取消时释放当前长连接。 参数说明:service 与最近一次完整观察使用同一作用域。 返回:变化时重新全量观察;同步丢失时明确失败。
Source§

fn validate_registration( &self, _plan: &RegistrationPlan, ) -> Result<(), DiscoveryError>

业务作用:在外部写入前校验 provider 特定注册字段与所有权键。 参数说明:plan 是不可变注册计划。 返回:读侧 provider 或不支持的字段必须拒绝。
Source§

fn registration_key(&self, plan: &RegistrationPlan) -> String

业务作用:计算可核对的远端注册键,用于同一 owner 内重复目标预检。 参数说明:plan 是已校验注册计划。 返回:包含真实后端作用域的键;不把配置连接别名当作远端身份。
Source§

fn service_key(&self, service: &str) -> Result<String, DiscoveryError>

业务作用:识别不同本地别名是否读取相同的后端服务集合,供宿主核对发布投影一致性。 参数说明:service 是已绑定的服务别名。 返回:不含凭据的后端查询键;有实际作用域的 adapter 必须包含地址、命名空间和过滤条件。
Source§

fn instance_key(&self, instance: &Instance) -> String

业务作用:保留同地址不同后端实例的身份,避免发现层按 IP/端口错误合并。 参数说明:instance 来自本 provider 的完整观察。 返回:当前服务作用域内的稳定非空键;后端有实例 ID 时应覆盖此默认地址键。
Source§

fn register<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _plan: &'life1 RegistrationPlan, _admission: &'life2 dyn WriteAdmission, ) -> Pin<Box<dyn Future<Output = Result<(), DiscoveryError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

业务作用:执行一次注册,不在方法外另起自动重放。 参数说明:plan 保留本次实例身份与端点,admission 必须用于实际传输提交。 返回:远端接纳或明确错误,传输结果不明由 owner 保留待核对记录。
Source§

fn renew<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _plan: &'life1 RegistrationPlan, _ready: bool, _admission: &'life2 dyn WriteAdmission, ) -> Pin<Box<dyn Future<Output = Result<(), DiscoveryError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

业务作用:续约既有记录或上报本地健康,不覆盖管理端禁用属性。 参数说明:plan 是既有注册,ready 是当前本地资格,admission 防止鉴权等待后继续发布。 返回:续约失败不能隐式变成重新注册。
Source§

fn renewal_interval(&self, _plan: &RegistrationPlan) -> Option<Duration>

业务作用:提供本后端需要的最大发送间隔。 参数说明:plan 指定检查模式与有效时限。 返回:无需主动保活时为空;否则 owner 按间隔监督。
Source§

fn supports_idempotent_renewal(&self, _plan: &RegistrationPlan) -> bool

业务作用:声明同一冻结身份与相同健康 payload 的续约能否在响应丢失后重复提交。 参数说明:plan 是已成功注册且尚未开始注销的固定计划。 返回:默认不允许;返回 true 的 provider 必须保证重复续约不重建身份、不覆盖管理属性,且不把它视为先前请求已停止执行的证明。
Source§

fn inspect<'life0, 'life1, 'async_trait>( &'life0 self, _plan: &'life1 RegistrationPlan, ) -> Pin<Box<dyn Future<Output = Result<RegistrationEvidence, DiscoveryError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

业务作用:核对本实例的在册及健康事实。 参数说明:plan 决定精确注册身份。 返回:查询失败与缺失、禁用、不健康明确区分。
Source§

fn deregister<'life0, 'life1, 'async_trait>( &'life0 self, _plan: &'life1 RegistrationPlan, ) -> Pin<Box<dyn Future<Output = Result<(), DiscoveryError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

业务作用:删除当前计划的远端记录,不消费本地事实。 参数说明:plan 用于确定注销目标。 返回:失败后 owner 仍能报告残留并安排同身份清理。

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> 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, 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.