- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 365
 
better docs and links between for Api::watch and watcher #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8bd1b2b
              9bd3a20
              6a7ad41
              42d4f39
              f651555
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -181,10 +181,39 @@ async fn step<K: Meta + Clone + DeserializeOwned + Send + 'static>( | |
| } | ||
| } | ||
| 
     | 
||
| /// Watches a Kubernetes Resource for changes | ||
| /// Watches a Kubernetes Resource for changes continuously | ||
| /// | ||
| /// Errors are propagated to the client as `Err`. Tries to recover (by reconnecting and resyncing as required) | ||
| /// if polled again after an error. | ||
| /// Creates an indefinite read stream through continual [`Api::watch`] calls, and keeping track | ||
| /// of [returned resource versions](https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes). | ||
| /// It tries to recover (by reconnecting and resyncing as required) if polled again after an error. | ||
| /// However, keep in mind that most terminal `TryStream` combinators (such as `TryFutureExt::try_for_each` | ||
| /// and `TryFutureExt::try_concat` will terminate eagerly if an `Error` reaches them. | ||
| /// | ||
| /// This is intended to provide a safe and atomic input interface for a state store like a [`reflector`], | ||
| /// direct users may want to flatten composite events with [`try_flatten_applied`]: | ||
| /// | ||
| /// ```no_run | ||
| /// use kube::{api::{Api, ListParams, Meta}, Client}; | ||
| /// use kube_runtime::{utils::try_flatten_applied, watcher}; | ||
| /// use k8s_openapi::api::core::v1::Pod; | ||
| /// use futures::{StreamExt, TryStreamExt}; | ||
| /// #[tokio::main] | ||
| /// async fn main() -> Result<(), kube_runtime::watcher::Error> { | ||
| /// let client = Client::try_default().await.unwrap(); | ||
| /// let pods: Api<Pod> = Api::namespaced(client, "apps"); | ||
| /// let watcher = watcher(pods, ListParams::default()); | ||
| /// try_flatten_applied(watcher) | ||
| /// .try_for_each(|p| async move { | ||
| /// println!("Applied: {}", Meta::name(&p)); | ||
| /// Ok(()) | ||
| /// }) | ||
| /// .await?; | ||
| /// Ok(()) | ||
| /// } | ||
| /// ``` | ||
| /// [`try_flatten_applied`]: super::utils::try_flatten_applied | ||
| /// [`reflector`]: super::reflector::reflector | ||
| /// [`Api::watch`]: https://docs.rs/kube/*/kube/struct.Api.html#method.watch | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought rustdoc was supposed to resolve these links automagically these days There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't able to get a cross-crate link to work :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to work for tokio-util (https://docs.rs/tokio-util/0.6.0/src/tokio_util/context.rs.html#22).. which direction did you test in? Makes sense that it would be tricker for links from  
      
  
  Member
      
  Author
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They have the  The other way around has the same problem for the time being.  | 
||
| /// | ||
| /// # Migration from `kube::runtime` | ||
| /// | ||
| 
          
            
          
           | 
    ||
Uh oh!
There was an error while loading. Please reload this page.