Struct etcd_discovery::EtcdDiscovery
source · pub struct EtcdDiscovery { /* private fields */ }Expand description
etcd 服务发现
Implementations§
source§impl EtcdDiscovery
impl EtcdDiscovery
sourcepub fn get_all_channel(&self) -> Channel
pub fn get_all_channel(&self) -> Channel
获取所有服务的channel, 负载均衡的channel
sourcepub fn get_etcd_client(&self) -> Client
pub fn get_etcd_client(&self) -> Client
获取etcd客户端
source§impl EtcdDiscovery
impl EtcdDiscovery
sourcepub async fn connect(
etcd_addr: impl AsRef<[&str]>,
options: Option<ConnectOptions>
) -> Result<Self, Error>
pub async fn connect( etcd_addr: impl AsRef<[&str]>, options: Option<ConnectOptions> ) -> Result<Self, Error>
连接etcd, 创建服务发现
sourcepub async fn service_discover(&mut self, prefix: &str) -> Result<(), Error>
pub async fn service_discover(&mut self, prefix: &str) -> Result<(), Error>
服务发现, prefix为服务前缀, 例如: /hello, 发现前缀/hello的所有服务
sourcepub fn get_service(&self, key: impl AsRef<str>) -> Option<Channel>
pub fn get_service(&self, key: impl AsRef<str>) -> Option<Channel>
获取一个服务的channel, 例如: /hello/1
pub fn remove_service(&mut self, key: impl AsRef<str>) -> Option<Channel>
pub async fn add_service(&self, key: impl AsRef<str>, url: &str)
Auto Trait Implementations§
impl !RefUnwindSafe for EtcdDiscovery
impl Send for EtcdDiscovery
impl Sync for EtcdDiscovery
impl Unpin for EtcdDiscovery
impl !UnwindSafe for EtcdDiscovery
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request