Skip to content

Commit 6d0c9b1

Browse files
authored
Remove abandoned StreamSubscribe implementation (#1470)
* Remove abandoned `StreamSubscribe` implementation This was never properly usable without further integration, and as such was never stabilised. It is replaced via #1449 Signed-off-by: clux <[email protected]> * forgot two imports Signed-off-by: clux <[email protected]> --------- Signed-off-by: clux <[email protected]>
1 parent 9eb5048 commit 6d0c9b1

File tree

3 files changed

+0
-303
lines changed

3 files changed

+0
-303
lines changed

kube-runtime/src/utils/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod event_modify;
77
#[cfg(feature = "unstable-runtime-predicates")] mod predicate;
88
mod reflect;
99
mod stream_backoff;
10-
#[cfg(feature = "unstable-runtime-subscribe")] pub mod stream_subscribe;
1110
mod watch_ext;
1211

1312
pub use backoff_reset_timer::ResetTimerBackoff;
@@ -17,8 +16,6 @@ pub use event_modify::EventModify;
1716
pub use predicate::{predicates, Predicate, PredicateFilter};
1817
pub use reflect::Reflect;
1918
pub use stream_backoff::StreamBackoff;
20-
#[cfg(feature = "unstable-runtime-subscribe")]
21-
pub use stream_subscribe::StreamSubscribe;
2219
pub use watch_ext::WatchStreamExt;
2320

2421
use futures::{

kube-runtime/src/utils/stream_subscribe.rs

-232
This file was deleted.

kube-runtime/src/utils/watch_ext.rs

-68
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#[cfg(feature = "unstable-runtime-predicates")]
22
use crate::utils::predicate::{Predicate, PredicateFilter};
3-
#[cfg(feature = "unstable-runtime-subscribe")]
4-
use crate::utils::stream_subscribe::StreamSubscribe;
53
use crate::{
64
utils::{event_flatten::EventFlatten, event_modify::EventModify, stream_backoff::StreamBackoff},
75
watcher,
@@ -128,72 +126,6 @@ pub trait WatchStreamExt: Stream {
128126
PredicateFilter::new(self, predicate)
129127
}
130128

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-
197129
/// Reflect a [`watcher()`] stream into a [`Store`] through a [`Writer`]
198130
///
199131
/// Returns the stream unmodified, but passes every [`watcher::Event`] through a [`Writer`].

0 commit comments

Comments
 (0)