Struct kube_runtime::watcher::Config

source ·
pub struct Config {
    pub label_selector: Option<String>,
    pub field_selector: Option<String>,
    pub timeout: Option<u32>,
    pub list_semantic: ListSemantic,
    pub initial_list_strategy: InitialListStrategy,
    pub page_size: Option<u32>,
    pub bookmarks: bool,
}
Expand description

Accumulates all options that can be used on the watcher invocation.

Fields§

§label_selector: Option<String>

A selector to restrict the list of returned objects by their labels.

Defaults to everything if None.

§field_selector: Option<String>

A selector to restrict the list of returned objects by their fields.

Defaults to everything if None.

§timeout: Option<u32>

Timeout for the list/watch call.

This limits the duration of the call, regardless of any activity or inactivity. If unset for a watch call, we will use 290s. We limit this to 295s due to inherent watch limitations.

§list_semantic: ListSemantic

Semantics for list calls.

Configures re-list for performance vs. consistency.

NB: This option only has an effect for InitialListStrategy::ListWatch.

§initial_list_strategy: InitialListStrategy

Control how the watcher fetches the initial list of objects.

  • ListWatch: The watcher will fetch the initial list of objects using a list call.
  • StreamingList: The watcher will fetch the initial list of objects using a watch call.

StreamingList is more efficient than ListWatch, but it requires the server to support streaming list bookmarks (opt-in feature gate in Kubernetes 1.27).

See upstream documentation on streaming lists, and the KEP.

§page_size: Option<u32>

Maximum number of objects retrieved per list operation resyncs.

This can reduce the memory consumption during resyncs, at the cost of requiring more API roundtrips to complete.

Defaults to 500. Note that None represents unbounded.

NB: This option only has an effect for InitialListStrategy::ListWatch.

§bookmarks: bool

Enables watch events with type “BOOKMARK”.

Requests watch bookmarks from the apiserver when enabled for improved watch precision and reduced list calls. This is default enabled and should generally not be turned off.

Implementations§

source§

impl Config

Builder interface to Config

Usage:

use kube::runtime::watcher::Config;
let wc = Config::default()
    .timeout(60)
    .labels("kubernetes.io/lifecycle=spot");
source

pub fn timeout(self, timeout_secs: u32) -> Self

Configure the timeout for list/watch calls

This limits the duration of the call, regardless of any activity or inactivity. Defaults to 290s

source

pub fn fields(self, field_selector: &str) -> Self

Configure the selector to restrict the list of returned objects by their fields.

Defaults to everything. Supports =, ==, !=, and can be comma separated: key1=value1,key2=value2. The server only supports a limited number of field queries per type.

source

pub fn labels(self, label_selector: &str) -> Self

Configure the selector to restrict the list of returned objects by their labels.

Defaults to everything. Supports =, ==, !=, and can be comma separated: key1=value1,key2=value2.

source

pub fn list_semantic(self, semantic: ListSemantic) -> Self

Sets list semantic to configure re-list performance and consistency

NB: This option only has an effect for InitialListStrategy::ListWatch.

source

pub fn any_semantic(self) -> Self

Sets list semantic to Any to improve list performance

NB: This option only has an effect for InitialListStrategy::ListWatch.

source

pub fn disable_bookmarks(self) -> Self

Disables watch bookmarks to simplify watch handling

This is not recommended to use with production watchers as it can cause desyncs. See #219 for details.

source

pub fn page_size(self, page_size: u32) -> Self

Limits the number of objects retrieved in each list operation during resync.

This can reduce the memory consumption during resyncs, at the cost of requiring more API roundtrips to complete.

NB: This option only has an effect for InitialListStrategy::ListWatch.

source

pub fn streaming_lists(self) -> Self

Kubernetes 1.27 Streaming Lists Sets list semantic to Stream to make use of watch bookmarks

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

impl PartialEq for Config

source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Same for T

§

type Output = T

Should always be Self
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