Skip to content

Commit

Permalink
Add usage example for reconcile_all_on
Browse files Browse the repository at this point in the history
  • Loading branch information
nightkr committed Jun 20, 2021
1 parent 508b7a7 commit 7420965
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions kube-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ serde_json = "1.0.61"
tokio = { version = "1.0.1", features = ["full", "test-util"] }
rand = "0.8.0"
schemars = "0.8.0"
tokio-stream = { version = "0.1.6", features = ["io-util"] }

[dev-dependencies.k8s-openapi]
version = "0.11.0"
Expand Down
27 changes: 27 additions & 0 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,33 @@ where
/// Trigger a reconciliation for all managed objects whenever `trigger` emits a value
///
/// For example, this can be used to reconcile all objects whenever the controller's configuration changes.
///
/// To reconcile all objects when a new line is entered:
///
/// ```rust
/// # async fn foo() {
/// use futures::stream::StreamExt;
/// use k8s_openapi::api::core::v1::ConfigMap;
/// use kube::{api::ListParams, Api, Client, ResourceExt};
/// use kube_runtime::controller::{Context, Controller, ReconcilerAction};
/// use std::convert::Infallible;
/// use tokio::io::{stdin, AsyncBufReadExt, BufReader};
/// use tokio_stream::wrappers::LinesStream;
/// Controller::new(
/// Api::<ConfigMap>::all(Client::try_default().await.unwrap()),
/// ListParams::default(),
/// )
/// .reconcile_all_on(LinesStream::new(BufReader::new(stdin()).lines()).map(|_| ()))
/// .run(
/// |o, _| async move {
/// println!("Reconciling {}", o.name());
/// Ok(ReconcilerAction { requeue_after: None })
/// },
/// |err: &Infallible, _| Err(err).unwrap(),
/// Context::new(()),
/// );
/// # }
/// ```
pub fn reconcile_all_on(mut self, trigger: impl Stream<Item = ()> + Send + Sync + 'static) -> Self {
let store = self.store();
let dyntype = self.dyntype.clone();
Expand Down

0 comments on commit 7420965

Please sign in to comment.