Skip to content

Commit

Permalink
Merge pull request #1625 from nightkr/docs/fix-reflect-shared-example
Browse files Browse the repository at this point in the history
Fix errors and warnings for the `.reflect_shared()` example
  • Loading branch information
nightkr authored Nov 3, 2024
2 parents a0fcd1e + 71de1bd commit 179936a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions kube-runtime/src/utils/watch_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ pub trait WatchStreamExt: Stream {
/// [`ReflectHandle`]: crate::reflector::dispatcher::ReflectHandle
/// ## Usage
/// ```no_run
/// # use futures::{pin_mut, Stream, StreamExt, TryStreamExt};
/// # use futures::StreamExt;
/// # use std::time::Duration;
/// # use tracing::{info, warn};
/// use kube::{Api, Client, ResourceExt};
/// use kube::{Api, ResourceExt};
/// use kube_runtime::{watcher, WatchStreamExt, reflector};
/// use k8s_openapi::api::apps::v1::Deployment;
/// # async fn wrapper() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -226,7 +226,7 @@ pub trait WatchStreamExt: Stream {
/// let deploys: Api<Deployment> = Api::default_namespaced(client);
/// let subscriber_buf_sz = 100;
/// let (reader, writer) = reflector::store_shared::<Deployment>(subscriber_buf_sz);
/// let subscriber = &writer.subscribe().unwrap();
/// let subscriber = writer.subscribe().unwrap();
///
/// tokio::spawn(async move {
/// // start polling the store once the reader is ready
Expand All @@ -238,6 +238,13 @@ pub trait WatchStreamExt: Stream {
/// }
/// });
///
/// tokio::spawn(async move {
/// // subscriber can be used to receive applied_objects
/// subscriber.for_each(|obj| async move {
/// info!("saw in subscriber {}", &obj.name_any())
/// }).await;
/// });
///
/// // configure the watcher stream and populate the store while polling
/// watcher(deploys, watcher::Config::default())
/// .reflect_shared(writer)
Expand All @@ -250,11 +257,6 @@ pub trait WatchStreamExt: Stream {
/// })
/// .await;
///
/// // subscriber can be used to receive applied_objects
/// subscriber.for_each(|obj| async move {
/// info!("saw in subscriber {}", &obj.name_any())
/// }).await;
///
/// # Ok(())
/// # }
/// ```
Expand Down

0 comments on commit 179936a

Please sign in to comment.