pub struct NamingService { /* private fields */ }Expand description
Naming service for service discovery and registration
Implementations§
Source§impl NamingService
impl NamingService
Sourcepub fn new(
rpc_client: Arc<RpcClient>,
namespace: &str,
cache_config: CacheConfig,
) -> Self
pub fn new( rpc_client: Arc<RpcClient>, namespace: &str, cache_config: CacheConfig, ) -> Self
Create a new NamingService with default WRR load balancer
Sourcepub fn with_balancer(
rpc_client: Arc<RpcClient>,
namespace: &str,
cache_config: CacheConfig,
balancer: Arc<dyn LoadBalancer>,
) -> Self
pub fn with_balancer( rpc_client: Arc<RpcClient>, namespace: &str, cache_config: CacheConfig, balancer: Arc<dyn LoadBalancer>, ) -> Self
Create a new NamingService with custom load balancer
Sourcepub fn with_group(self, group_name: &str) -> Self
pub fn with_group(self, group_name: &str) -> Self
Set default group name
Sourcepub async fn register_instance(
&self,
service_name: &str,
group_name: &str,
instance: Instance,
) -> Result<()>
pub async fn register_instance( &self, service_name: &str, group_name: &str, instance: Instance, ) -> Result<()>
Register a service instance
Sourcepub async fn register_instance_simple(
&self,
service_name: &str,
ip: &str,
port: i32,
) -> Result<()>
pub async fn register_instance_simple( &self, service_name: &str, ip: &str, port: i32, ) -> Result<()>
Register a service instance with simplified parameters
Sourcepub async fn deregister_instance(
&self,
service_name: &str,
group_name: &str,
instance: Instance,
) -> Result<()>
pub async fn deregister_instance( &self, service_name: &str, group_name: &str, instance: Instance, ) -> Result<()>
Deregister a service instance
Sourcepub async fn deregister_instance_simple(
&self,
service_name: &str,
ip: &str,
port: i32,
) -> Result<()>
pub async fn deregister_instance_simple( &self, service_name: &str, ip: &str, port: i32, ) -> Result<()>
Deregister a service instance with simplified parameters
Sourcepub async fn update_instance(
&self,
service_name: &str,
group_name: &str,
instance: Instance,
) -> Result<()>
pub async fn update_instance( &self, service_name: &str, group_name: &str, instance: Instance, ) -> Result<()>
Update a service instance
Sourcepub async fn update_instance_simple(
&self,
service_name: &str,
ip: &str,
port: i32,
weight: f64,
enabled: bool,
) -> Result<()>
pub async fn update_instance_simple( &self, service_name: &str, ip: &str, port: i32, weight: f64, enabled: bool, ) -> Result<()>
Update a service instance with simplified parameters
Sourcepub async fn get_service(
&self,
service_name: &str,
group_name: &str,
clusters: &[String],
) -> Result<Service>
pub async fn get_service( &self, service_name: &str, group_name: &str, clusters: &[String], ) -> Result<Service>
Get service information with cluster filtering
Sourcepub async fn get_all_instances(
&self,
service_name: &str,
group_name: &str,
) -> Result<Vec<Instance>>
pub async fn get_all_instances( &self, service_name: &str, group_name: &str, ) -> Result<Vec<Instance>>
Get all instances of a service
Sourcepub async fn select_instances(
&self,
service_name: &str,
group_name: &str,
healthy_only: bool,
) -> Result<Vec<Instance>>
pub async fn select_instances( &self, service_name: &str, group_name: &str, healthy_only: bool, ) -> Result<Vec<Instance>>
Select healthy instances of a service
Sourcepub async fn select_one_healthy_instance(
&self,
service_name: &str,
group_name: &str,
) -> Result<Instance>
pub async fn select_one_healthy_instance( &self, service_name: &str, group_name: &str, ) -> Result<Instance>
Select one healthy instance using the configured load balancer
By default, uses Weighted Round Robin (WRR) algorithm which distributes traffic proportionally to instance weights.
Sourcepub async fn get_services_of_server(
&self,
group_name: &str,
page_no: i32,
page_size: i32,
) -> Result<(i32, Vec<String>)>
pub async fn get_services_of_server( &self, group_name: &str, page_no: i32, page_size: i32, ) -> Result<(i32, Vec<String>)>
Get list of services
Sourcepub async fn subscribe<L>(
&self,
service_name: &str,
group_name: &str,
listener: L,
) -> Result<()>where
L: ServiceListener + 'static,
pub async fn subscribe<L>(
&self,
service_name: &str,
group_name: &str,
listener: L,
) -> Result<()>where
L: ServiceListener + 'static,
Subscribe to service changes
Sourcepub async fn subscribe_callback<F>(
&self,
service_name: &str,
group_name: &str,
callback: F,
) -> Result<()>
pub async fn subscribe_callback<F>( &self, service_name: &str, group_name: &str, callback: F, ) -> Result<()>
Subscribe with callback
Sourcepub async fn unsubscribe(
&self,
service_name: &str,
group_name: &str,
) -> Result<()>
pub async fn unsubscribe( &self, service_name: &str, group_name: &str, ) -> Result<()>
Unsubscribe from service changes
Sourcepub async fn get_server_status(&self) -> Result<String>
pub async fn get_server_status(&self) -> Result<String>
Get server status
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NamingService
impl !RefUnwindSafe for NamingService
impl Send for NamingService
impl Sync for NamingService
impl Unpin for NamingService
impl !UnwindSafe for NamingService
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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>
T in a tonic::Request