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
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) -> Self
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
sourcepub fn fields(self, field_selector: &str) -> Self
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.
sourcepub fn labels(self, label_selector: &str) -> Self
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
.
sourcepub fn labels_from(self, selector: &Selector) -> Self
pub fn labels_from(self, selector: &Selector) -> Self
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) -> Self
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
.
sourcepub fn any_semantic(self) -> Self
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
.
sourcepub fn disable_bookmarks(self) -> Self
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.
sourcepub fn page_size(self, page_size: u32) -> Self
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
.
sourcepub fn streaming_lists(self) -> Self
pub fn streaming_lists(self) -> Self
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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