pub struct LocalProvider { /* private fields */ }Expand description
静态实例或 DNS 地址的只读适配器,不提供注册中心健康证据或写入能力。
Implementations§
Source§impl LocalProvider
impl LocalProvider
Sourcepub fn static_services(
services: BTreeMap<String, Vec<Instance>>,
) -> Result<Self>
pub fn static_services( services: BTreeMap<String, Vec<Instance>>, ) -> Result<Self>
业务作用:冻结普通服务的静态实例表,不产生自注册副作用。
参数说明:
services:为服务到完整实例列表的显式映射。
返回:合法静态表对应的只读 provider。
Sourcepub fn dns_services(services: BTreeMap<String, DnsService>) -> Result<Self>
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
impl ManagedProvider for LocalProvider
Source§fn capabilities(&self) -> Capabilities
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,
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,
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,
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,
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_streams(&self) -> u32
fn change_wait_streams(&self) -> u32
业务作用:为一次变更等待预留实际可能并发的后端长请求额度。 Read more
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,
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,
业务作用:等待服务或端点变化,调用方取消时释放当前长连接。 Read more
Source§fn validate_registration(
&self,
_plan: &RegistrationPlan,
) -> Result<(), DiscoveryError>
fn validate_registration( &self, _plan: &RegistrationPlan, ) -> Result<(), DiscoveryError>
业务作用:在外部写入前校验 provider 特定注册字段与所有权键。 Read more
Source§fn registration_key(&self, plan: &RegistrationPlan) -> String
fn registration_key(&self, plan: &RegistrationPlan) -> String
业务作用:计算可核对的远端注册键,用于同一 owner 内重复目标预检。 Read more
Source§fn service_key(&self, service: &str) -> Result<String, DiscoveryError>
fn service_key(&self, service: &str) -> Result<String, DiscoveryError>
业务作用:识别不同本地别名是否读取相同的后端服务集合,供宿主核对发布投影一致性。 Read more
Source§fn instance_key(&self, instance: &Instance) -> String
fn instance_key(&self, instance: &Instance) -> String
业务作用:保留同地址不同后端实例的身份,避免发现层按 IP/端口错误合并。 Read more
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,
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,
业务作用:执行一次注册,不在方法外另起自动重放。 Read more
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,
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,
业务作用:续约既有记录或上报本地健康,不覆盖管理端禁用属性。 Read more
Source§fn renewal_interval(&self, _plan: &RegistrationPlan) -> Option<Duration>
fn renewal_interval(&self, _plan: &RegistrationPlan) -> Option<Duration>
业务作用:提供本后端需要的最大发送间隔。 Read more
Source§fn supports_idempotent_renewal(&self, _plan: &RegistrationPlan) -> bool
fn supports_idempotent_renewal(&self, _plan: &RegistrationPlan) -> bool
业务作用:声明同一冻结身份与相同健康 payload 的续约能否在响应丢失后重复提交。 Read more
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,
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,
业务作用:核对本实例的在册及健康事实。 Read more
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,
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,
业务作用:删除当前计划的远端记录,不消费本地事实。 Read more
Auto Trait Implementations§
impl !Freeze for LocalProvider
impl Forget for LocalProvider
impl Move for LocalProvider
impl RefUnwindSafe for LocalProvider
impl Send for LocalProvider
impl Sync for LocalProvider
impl Unpin for LocalProvider
impl UnsafeUnpin for LocalProvider
impl UnwindSafe for LocalProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more