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,
}
runtime
only.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
impl Config
Builder interface to Config
Usage:
use kube::runtime::watcher::Config;
let wc = Config::default()
.timeout(60)
.labels("kubernetes.io/lifecycle=spot");
Sourcepub fn timeout(self, timeout_secs: u32) -> Config
pub fn timeout(self, timeout_secs: u32) -> Config
Configure the timeout for list/watch calls
This limits the duration of the call, regardless of any activity or inactivity. Defaults to 290s
Sourcepub fn fields(self, field_selector: &str) -> Config
pub fn fields(self, field_selector: &str) -> Config
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.
Sourcepub fn labels(self, label_selector: &str) -> Config
pub fn labels(self, label_selector: &str) -> Config
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
.
Sourcepub fn labels_from(self, selector: &Selector) -> Config
pub fn labels_from(self, selector: &Selector) -> Config
Configure typed label selectors
Configure typed selectors from Selector
and Expression
lists.
use kube_runtime::watcher::Config;
use kube_client::core::{Expression, Selector, ParseExpressionError};
use k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector;
let selector: Selector = Expression::In("env".into(), ["development".into(), "sandbox".into()].into()).into();
let cfg = Config::default().labels_from(&selector);
let cfg = Config::default().labels_from(&Expression::Exists("foo".into()).into());
let selector: Selector = LabelSelector::default().try_into()?;
let cfg = Config::default().labels_from(&selector);
Sourcepub fn list_semantic(self, semantic: ListSemantic) -> Config
pub fn list_semantic(self, semantic: ListSemantic) -> Config
Sets list semantic to configure re-list performance and consistency
NB: This option only has an effect for InitialListStrategy::ListWatch
.
Sourcepub fn any_semantic(self) -> Config
pub fn any_semantic(self) -> Config
Sets list semantic to Any
to improve list performance
NB: This option only has an effect for InitialListStrategy::ListWatch
.
Sourcepub fn disable_bookmarks(self) -> Config
pub fn disable_bookmarks(self) -> Config
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.
Sourcepub fn page_size(self, page_size: u32) -> Config
pub fn page_size(self, page_size: u32) -> Config
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
.
Sourcepub fn streaming_lists(self) -> Config
pub fn streaming_lists(self) -> Config
Kubernetes 1.27 Streaming Lists
Sets list semantic to Stream
to make use of watch bookmarks
Trait Implementations§
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more