pub struct ServiceConfig {
pub nacos_addr: String,
pub namespace: String,
pub service_name: String,
pub group: String,
pub service_host: String,
pub service_port: u16,
pub weight: f64,
pub ephemeral: bool,
pub auth: Option<(String, String)>,
pub metadata: HashMap<String, String>,
}Expand description
Full configuration required to register a service instance.
Build one via ServiceConfig::builder or ServiceConfig::from_env.
Fields§
§nacos_addr: StringNacos server address, formatted as host:port.
namespace: StringNacos namespace id.
service_name: StringService name.
group: StringService group, defaults to DEFAULT_GROUP.
service_host: StringAdvertised host (IP or hostname) registered to Nacos.
service_port: u16Advertised port registered to Nacos.
weight: f64Instance weight, defaults to DEFAULT_WEIGHT.
ephemeral: boolWhether the instance is ephemeral, defaults to true.
auth: Option<(String, String)>Auth credentials (username, password); both must be provided or neither.
metadata: HashMap<String, String>Extra metadata. META_GRPC_PORT is auto-populated with the port unless the user
supplies their own value.
Implementations§
Source§impl ServiceConfig
impl ServiceConfig
Sourcepub fn builder() -> ServiceConfigBuilder
pub fn builder() -> ServiceConfigBuilder
Create a fresh, empty builder.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Load configuration from environment variables.
Required: NACOS_ADDR, NACOS_NAMESPACE,
SERVICE_ADDR, SERVICE_NAME.
Optional: SERVICE_HOST (falls back to the local IP),
NACOS_USERNAME + NACOS_PASSWORD
(both must be present, or both absent).
Trait Implementations§
Source§impl Clone for ServiceConfig
impl Clone for ServiceConfig
Source§fn clone(&self) -> ServiceConfig
fn clone(&self) -> ServiceConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ServiceConfig
impl RefUnwindSafe for ServiceConfig
impl Send for ServiceConfig
impl Sync for ServiceConfig
impl Unpin for ServiceConfig
impl UnsafeUnpin for ServiceConfig
impl UnwindSafe for ServiceConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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