Skip to main content

Instance

Struct Instance 

Source
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: String

The 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: String

Unique 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: u64

Seconds 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: u64

Unix seconds when the registry last heard from it.

Implementations§

Source§

impl Instance

Source

pub fn new( service: impl Into<String>, host: impl Into<String>, port: u16, ) -> Instance

Source

pub fn id(self, id: impl Into<String>) -> Instance

Source

pub fn secure(self, secure: bool) -> Instance

Source

pub fn status(self, status: Status) -> Instance

Source

pub fn meta(self, key: impl Into<String>, value: impl Into<String>) -> Instance

Source

pub fn renew_every(self, seconds: u64) -> Instance

Source

pub fn url(&self) -> String

Where to send a request.

Source

pub fn zone(&self) -> Option<&str>

Source

pub fn meta_value(&self, key: &str) -> Option<&str>

Source

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.

Trait Implementations§

Source§

impl Clone for Instance

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Instance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.