|
1 | 1 | #[cfg(feature = "unstable-runtime-predicates")]
|
2 | 2 | use crate::utils::predicate::{Predicate, PredicateFilter};
|
3 |
| -#[cfg(feature = "unstable-runtime-subscribe")] |
4 |
| -use crate::utils::stream_subscribe::StreamSubscribe; |
5 | 3 | use crate::{
|
6 | 4 | utils::{event_flatten::EventFlatten, event_modify::EventModify, stream_backoff::StreamBackoff},
|
7 | 5 | watcher,
|
@@ -128,72 +126,6 @@ pub trait WatchStreamExt: Stream {
|
128 | 126 | PredicateFilter::new(self, predicate)
|
129 | 127 | }
|
130 | 128 |
|
131 |
| - /// Create a [`StreamSubscribe`] from a [`watcher()`] stream. |
132 |
| - /// |
133 |
| - /// The [`StreamSubscribe::subscribe()`] method which allows additional consumers |
134 |
| - /// of events from a stream without consuming the stream itself. |
135 |
| - /// |
136 |
| - /// If a subscriber begins to lag behind the stream, it will receive an [`Error::Lagged`](crate::utils::stream_subscribe::Error::Lagged) |
137 |
| - /// error. The subscriber can then decide to abort its task or tolerate the lost events. |
138 |
| - /// |
139 |
| - /// If the [`Stream`] is dropped or ends, any [`StreamSubscribe::subscribe()`] streams |
140 |
| - /// will also end. |
141 |
| - /// |
142 |
| - /// **NB**: This is constructor requires an [`unstable`](https://github.com/kube-rs/kube/blob/main/kube-runtime/Cargo.toml#L17-L21) feature. |
143 |
| - /// |
144 |
| - /// ## Warning |
145 |
| - /// |
146 |
| - /// If the primary [`Stream`] is not polled, the [`StreamSubscribe::subscribe()`] streams |
147 |
| - /// will never receive any events. |
148 |
| - /// |
149 |
| - /// # Usage |
150 |
| - /// |
151 |
| - /// ``` |
152 |
| - /// use futures::{Stream, StreamExt}; |
153 |
| - /// use std::{fmt::Debug, sync::Arc}; |
154 |
| - /// use kube_runtime::{watcher, WatchStreamExt}; |
155 |
| - /// |
156 |
| - /// fn explain_events<K, S>( |
157 |
| - /// stream: S, |
158 |
| - /// ) -> ( |
159 |
| - /// impl Stream<Item = Arc<Result<watcher::Event<K>, watcher::Error>>> + Send + Sized + 'static, |
160 |
| - /// impl Stream<Item = String> + Send + Sized + 'static, |
161 |
| - /// ) |
162 |
| - /// where |
163 |
| - /// K: Clone + Debug + Send + Sync + 'static, |
164 |
| - /// S: Stream<Item = Result<watcher::Event<K>, watcher::Error>> + Send + Sized + 'static, |
165 |
| - /// { |
166 |
| - /// // Create a stream that can be subscribed to |
167 |
| - /// let stream_subscribe = stream.stream_subscribe(); |
168 |
| - /// // Create a subscription to that stream |
169 |
| - /// let subscription = stream_subscribe.subscribe(); |
170 |
| - /// |
171 |
| - /// // Create a stream of descriptions of the events |
172 |
| - /// let explain_stream = subscription.filter_map(|event| async move { |
173 |
| - /// // We don't care about lagged events so we can throw that error away |
174 |
| - /// match event.ok()?.as_ref() { |
175 |
| - /// Ok(watcher::Event::Applied(event)) => { |
176 |
| - /// Some(format!("An object was added or modified: {event:?}")) |
177 |
| - /// } |
178 |
| - /// Ok(_) => todo!("explain other events"), |
179 |
| - /// // We don't care about watcher errors either |
180 |
| - /// Err(_) => None, |
181 |
| - /// } |
182 |
| - /// }); |
183 |
| - /// |
184 |
| - /// // We now still have the original stream, and a secondary stream of explanations |
185 |
| - /// (stream_subscribe, explain_stream) |
186 |
| - /// } |
187 |
| - /// ``` |
188 |
| - #[cfg(feature = "unstable-runtime-subscribe")] |
189 |
| - fn stream_subscribe<K>(self) -> StreamSubscribe<Self> |
190 |
| - where |
191 |
| - Self: Stream<Item = Result<watcher::Event<K>, watcher::Error>> + Send + Sized + 'static, |
192 |
| - K: Clone, |
193 |
| - { |
194 |
| - StreamSubscribe::new(self) |
195 |
| - } |
196 |
| - |
197 | 129 | /// Reflect a [`watcher()`] stream into a [`Store`] through a [`Writer`]
|
198 | 130 | ///
|
199 | 131 | /// Returns the stream unmodified, but passes every [`watcher::Event`] through a [`Writer`].
|
|
0 commit comments