Struct kube_coordinate::Config

source ·
pub struct Config {
    pub name: String,
    pub namespace: String,
    pub identity: String,
    pub manager: String,
    pub lease_duration: Duration,
    pub renew_deadline: Duration,
    pub retry_period: Duration,
    pub api_timeout: Duration,
}
Expand description

Configuration for leader election.

Fields§

§name: String

The name of the lease object.

§namespace: String

The namespace of the lease object.

§identity: String

The identity to use when the lease is acquired.

Typically this value will directly correspond to the name of the pod running this process.

§manager: String

The name to use for Server-Side Apply management group.

Typically this value corresponds to the name of the group of controllers of which this leader elector is a part. Note well that this value should be the same across the entire management group and should be distinct from the identity parameter.

§lease_duration: Duration

The duration that non-leader candidates will wait to force acquire leadership. This is measured against time of last observed ack.

A client needs to wait a full lease_duration without observing a change to the record before it can attempt to take over. When all clients are shutdown and a new set of clients are started with different names against the same leader record, they must wait the full lease_duration before attempting to acquire the lease. Thus lease_duration should be as short as possible (within your tolerance for clock skew rate) to avoid possible long waits in such a scenario.

Core clients default this value to 15 seconds.

§renew_deadline: Duration

The duration that the current lease holder will retry refreshing the lease.

Core clients default this value to 10 seconds.

§retry_period: Duration

The duration which leader elector clients should wait between tries of actions.

Core clients default this value to 2 seconds.

§api_timeout: Duration

API timeout to use for interacting with the K8s API.

Implementations§

source§

impl Config

source

pub fn name(self, val: &str) -> Self

Set the name of the lease object.

source

pub fn namespace(self, val: &str) -> Self

Set the namespace of the lease object.

source

pub fn identity(self, val: &str) -> Self

Set the identity to use when the lease is acquired.

source

pub fn manager(self, val: &str) -> Self

Set the name to use for Server-Side Apply management group.

source

pub fn lease_duration(self, val: Duration) -> Self

Set the duration that non-leader candidates will wait to force acquire leadership. This is measured against time of last observed ack.

source

pub fn renew_deadline(self, val: Duration) -> Self

Set the duration that the current lease holder will retry refreshing the lease.

source

pub fn retry_period(self, val: Duration) -> Self

Set the duration which leader elector clients should wait between tries of actions.

source

pub fn api_timeout(self, val: Duration) -> Self

Set the API timeout to use for interacting with the K8s API.

source

pub fn validate(&self) -> Result<()>

Finish building leader elector config by validating this config builder.

§Errors

Will return Error::ConfigError if this member’s fields are invalid according to the following constraints:

  • name must not be an empty string;
  • namespace must not be an empty string;
  • identity must not be an empty string;
  • manager must not be an empty string;
  • lease_duration must be greater than renew_deadline;
  • renew_deadline must be greater than (JITTER_FACTOR * retry_period.num_seconds());
  • lease_duration must be >= 1 second;
  • renew_deadline must be >= 1 second;
  • retry_period must be >= 1 second;
  • apu_timeout must be >= 1 second;

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Config

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Config

source§

fn default() -> Self

Returns the “default value” for a type. 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more