pub struct Instance {
pub service: String,
pub id: String,
pub host: String,
pub port: u16,
pub secure: bool,
pub status: Status,
pub metadata: Vec<(String, String)>,
pub renew_interval: u64,
pub last_seen: u64,
}Expand description
A registered instance.
Fields§
§service: StringThe service this belongs to. Upper-cased, because Eureka upper-cases application names and a registry that disagrees with its own clients about the name of a service is worse than one that shouts.
id: StringUnique within the service. host:port when nothing better is given.
host: String§port: u16§secure: bool§status: Status§metadata: Vec<(String, String)>Free-form, and the place zone and version live. A registry that fixed the set of things an instance may say about itself would be a registry somebody works around within a month.
renew_interval: u64Seconds between heartbeats, as the instance says it will send them.
The instance decides, not the registry: only the instance knows whether it is a service that can promise every five seconds or a batch worker that cannot.
last_seen: u64Unix seconds when the registry last heard from it.
Implementations§
Source§impl Instance
impl Instance
pub fn new( service: impl Into<String>, host: impl Into<String>, port: u16, ) -> Instance
pub fn id(self, id: impl Into<String>) -> Instance
pub fn secure(self, secure: bool) -> Instance
pub fn status(self, status: Status) -> Instance
pub fn meta(self, key: impl Into<String>, value: impl Into<String>) -> Instance
pub fn renew_every(self, seconds: u64) -> Instance
pub fn zone(&self) -> Option<&str>
pub fn meta_value(&self, key: &str) -> Option<&str>
Sourcepub fn fresh_at(&self, now: u64) -> bool
pub fn fresh_at(&self, now: u64) -> bool
Whether the registry has heard from it recently enough.
Three missed heartbeats, not one. A single miss is a garbage collection pause or a dropped packet; three in a row is a service that has stopped talking. Eureka’s own default is the same shape — a ninety-second lease against a thirty-second renewal.