pub struct ServiceInstance {
pub service_type: String,
pub instance_id: String,
pub address: SocketAddr,
pub namespace: Option<String>,
pub version: Option<String>,
pub tags: HashMap<String, String>,
pub metadata: InstanceMetadata,
pub healthy: bool,
pub weight: u32,
}Expand description
服务实例
Fields§
§service_type: String服务类型(如 “signaling-online”, “message-orchestrator”)
instance_id: String实例 ID(唯一标识)
address: SocketAddr服务地址
namespace: Option<String>命名空间
version: Option<String>版本
自定义标签(用于过滤和路由)
metadata: InstanceMetadata元数据
healthy: bool是否健康
weight: u32权重(用于负载均衡)
Implementations§
Source§impl ServiceInstance
impl ServiceInstance
Sourcepub fn new(
service_type: impl Into<String>,
instance_id: impl Into<String>,
address: SocketAddr,
) -> ServiceInstance
pub fn new( service_type: impl Into<String>, instance_id: impl Into<String>, address: SocketAddr, ) -> ServiceInstance
创建新的服务实例
Sourcepub fn with_namespace(self, namespace: impl Into<String>) -> ServiceInstance
pub fn with_namespace(self, namespace: impl Into<String>) -> ServiceInstance
设置命名空间
Sourcepub fn with_version(self, version: impl Into<String>) -> ServiceInstance
pub fn with_version(self, version: impl Into<String>) -> ServiceInstance
设置版本
Sourcepub fn with_tag(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> ServiceInstance
pub fn with_tag( self, key: impl Into<String>, value: impl Into<String>, ) -> ServiceInstance
添加标签
Sourcepub fn with_weight(self, weight: u32) -> ServiceInstance
pub fn with_weight(self, weight: u32) -> ServiceInstance
设置权重
Sourcepub fn with_health(self, healthy: bool) -> ServiceInstance
pub fn with_health(self, healthy: bool) -> ServiceInstance
设置健康状态
Sourcepub fn to_http_url(&self) -> String
pub fn to_http_url(&self) -> String
转换为 HTTP URL
Sourcepub fn to_grpc_uri(&self) -> String
pub fn to_grpc_uri(&self) -> String
转换为 gRPC URI
检查是否匹配标签过滤器
Sourcepub fn matches_version(&self, version: Option<&str>) -> bool
pub fn matches_version(&self, version: Option<&str>) -> bool
检查是否匹配版本
Sourcepub fn matches_namespace(&self, namespace: Option<&str>) -> bool
pub fn matches_namespace(&self, namespace: Option<&str>) -> bool
检查是否匹配命名空间
Trait Implementations§
Source§impl Clone for ServiceInstance
impl Clone for ServiceInstance
Source§fn clone(&self) -> ServiceInstance
fn clone(&self) -> ServiceInstance
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ServiceInstance
impl Debug for ServiceInstance
Source§impl<'de> Deserialize<'de> for ServiceInstance
impl<'de> Deserialize<'de> for ServiceInstance
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ServiceInstance, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ServiceInstance, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ServiceInstance
Source§impl PartialEq for ServiceInstance
impl PartialEq for ServiceInstance
Source§impl Serialize for ServiceInstance
impl Serialize for ServiceInstance
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for ServiceInstance
Auto Trait Implementations§
impl Freeze for ServiceInstance
impl RefUnwindSafe for ServiceInstance
impl Send for ServiceInstance
impl Sync for ServiceInstance
impl Unpin for ServiceInstance
impl UnsafeUnpin for ServiceInstance
impl UnwindSafe for ServiceInstance
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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