|
1 | 1 | //! Provides an abstraction of several async runtimes |
2 | 2 | //! |
3 | | -//! This allows OpenTelemetry to work with any current or future runtime. There are currently |
4 | | -//! builtin implementations for [Tokio] and [async-std]. |
| 3 | +//! This allows OpenTelemetry to work with any current or future runtime. There is currently |
| 4 | +//! built-in implementation for [Tokio]. |
5 | 5 | //! |
6 | 6 | //! [Tokio]: https://crates.io/crates/tokio |
7 | | -//! [async-std]: https://crates.io/crates/async-std |
8 | 7 |
|
9 | 8 | use futures_util::stream::{unfold, Stream}; |
10 | 9 | use std::{fmt::Debug, future::Future, time::Duration}; |
11 | 10 | use thiserror::Error; |
12 | 11 |
|
13 | | -/// A runtime is an abstraction of an async runtime like [Tokio] or [async-std]. It allows |
| 12 | +/// A runtime is an abstraction of an async runtime like [Tokio]. It allows |
14 | 13 | /// OpenTelemetry to work with any current and hopefully future runtime implementations. |
15 | 14 | /// |
16 | 15 | /// [Tokio]: https://crates.io/crates/tokio |
17 | | -/// [async-std]: https://crates.io/crates/async-std |
18 | 16 | /// |
19 | 17 | /// # Note |
20 | 18 | /// |
@@ -139,34 +137,6 @@ impl Runtime for TokioCurrentThread { |
139 | 137 | } |
140 | 138 | } |
141 | 139 |
|
142 | | -/// Runtime implementation, which works with async-std. |
143 | | -#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))] |
144 | | -#[cfg_attr( |
145 | | - docsrs, |
146 | | - doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))) |
147 | | -)] |
148 | | -#[derive(Debug, Clone)] |
149 | | -pub struct AsyncStd; |
150 | | - |
151 | | -#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))] |
152 | | -#[cfg_attr( |
153 | | - docsrs, |
154 | | - doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))) |
155 | | -)] |
156 | | -impl Runtime for AsyncStd { |
157 | | - fn spawn<F>(&self, future: F) |
158 | | - where |
159 | | - F: Future<Output = ()> + Send + 'static, |
160 | | - { |
161 | | - #[allow(clippy::let_underscore_future)] |
162 | | - let _ = async_std::task::spawn(future); |
163 | | - } |
164 | | - |
165 | | - fn delay(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static { |
166 | | - async_std::task::sleep(duration) |
167 | | - } |
168 | | -} |
169 | | - |
170 | 140 | /// `RuntimeChannel` is an extension to [`Runtime`]. Currently, it provides a |
171 | 141 | /// channel that is used by the [log] and [span] batch processors. |
172 | 142 | /// |
@@ -275,32 +245,3 @@ impl RuntimeChannel for TokioCurrentThread { |
275 | 245 | ) |
276 | 246 | } |
277 | 247 | } |
278 | | - |
279 | | -#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))] |
280 | | -impl<T: Send> TrySend for async_std::channel::Sender<T> { |
281 | | - type Message = T; |
282 | | - |
283 | | - fn try_send(&self, item: Self::Message) -> Result<(), TrySendError> { |
284 | | - self.try_send(item).map_err(|err| match err { |
285 | | - async_std::channel::TrySendError::Full(_) => TrySendError::ChannelFull, |
286 | | - async_std::channel::TrySendError::Closed(_) => TrySendError::ChannelClosed, |
287 | | - }) |
288 | | - } |
289 | | -} |
290 | | - |
291 | | -#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))] |
292 | | -#[cfg_attr( |
293 | | - docsrs, |
294 | | - doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))) |
295 | | -)] |
296 | | -impl RuntimeChannel for AsyncStd { |
297 | | - type Receiver<T: Debug + Send> = async_std::channel::Receiver<T>; |
298 | | - type Sender<T: Debug + Send> = async_std::channel::Sender<T>; |
299 | | - |
300 | | - fn batch_message_channel<T: Debug + Send>( |
301 | | - &self, |
302 | | - capacity: usize, |
303 | | - ) -> (Self::Sender<T>, Self::Receiver<T>) { |
304 | | - async_std::channel::bounded(capacity) |
305 | | - } |
306 | | -} |
0 commit comments