From 19941156b43ec58370d0d1369174ec84400e9bc9 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Fri, 28 Aug 2026 22:40:54 +0700 Subject: [PATCH] fix(ci): gate event crate doctest behind mem feature and apply rustfmt The crate-root doctest used InMemoryEventBus/TypedEventBus (gated behind the 'mem' feature), so `cargo test -p mytheclipse-event --no-default-features --features amqp|nats` failed to compile the doctest (E0432). The example is now no_run with the mem-dependent imports inside a #[cfg(feature="mem")] main, so it compiles (and runs) when mem is on and degrades to an empty main when off. Also apply rustfmt to mytheclipse-config/dynamic.rs and mytheclipse-storage/{gcs,s3}.rs to satisfy cargo fmt --all --check. --- crates/mytheclipse-config/src/dynamic.rs | 5 ++++- crates/mytheclipse-event/src/lib.rs | 25 +++++++++++++++--------- crates/mytheclipse-storage/src/gcs.rs | 5 ++++- crates/mytheclipse-storage/src/s3.rs | 13 +++++++++--- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/crates/mytheclipse-config/src/dynamic.rs b/crates/mytheclipse-config/src/dynamic.rs index b4ac17b..420cee6 100644 --- a/crates/mytheclipse-config/src/dynamic.rs +++ b/crates/mytheclipse-config/src/dynamic.rs @@ -49,7 +49,10 @@ impl DynamicConfig { /// Replaces the current value and notifies subscribers. pub fn set(&self, new: T) { - *self.inner.write().expect("mytheclipse-config: RwLock poisoned") = new; + *self + .inner + .write() + .expect("mytheclipse-config: RwLock poisoned") = new; let _ = self.tx.send(()); } diff --git a/crates/mytheclipse-event/src/lib.rs b/crates/mytheclipse-event/src/lib.rs index 5dc7b8e..0752cdb 100644 --- a/crates/mytheclipse-event/src/lib.rs +++ b/crates/mytheclipse-event/src/lib.rs @@ -15,20 +15,27 @@ //! //! ## Example //! -//! ``` -//! use mytheclipse_event::{EventBus, InMemoryEventBus, TypedEventBus}; +//! The in-memory + typed bus (`mem` feature, on by default): +//! +//! ```no_run //! use serde::{Deserialize, Serialize}; //! //! #[derive(Debug, Serialize, Deserialize, PartialEq)] //! struct OrderCreated { id: u64 } //! -//! # #[tokio::main] async fn main() { -//! let bus = TypedEventBus::new(InMemoryEventBus::default()); -//! let mut sub = bus.subscribe::("orders").await.unwrap(); -//! bus.publish("orders", &OrderCreated { id: 42 }).await.unwrap(); -//! let event = sub.recv().await.unwrap(); -//! assert_eq!(event, OrderCreated { id: 42 }); -//! # } +//! #[cfg(feature = "mem")] +//! #[tokio::main] +//! async fn main() { +//! use mytheclipse_event::{EventBus, InMemoryEventBus, TypedEventBus}; +//! let bus = TypedEventBus::new(InMemoryEventBus::default()); +//! let mut sub = bus.subscribe::("orders").await.unwrap(); +//! bus.publish("orders", &OrderCreated { id: 42 }).await.unwrap(); +//! let event = sub.recv().await.unwrap(); +//! assert_eq!(event, OrderCreated { id: 42 }); +//! } +//! +//! #[cfg(not(feature = "mem"))] +//! fn main() {} //! ``` pub mod traits; diff --git a/crates/mytheclipse-storage/src/gcs.rs b/crates/mytheclipse-storage/src/gcs.rs index ae6297b..9481925 100644 --- a/crates/mytheclipse-storage/src/gcs.rs +++ b/crates/mytheclipse-storage/src/gcs.rs @@ -160,6 +160,9 @@ mod tests { .await .unwrap(); assert_eq!(data, b"hello gcs"); - storage.delete("mytheclipse-storage-test.txt").await.unwrap(); + storage + .delete("mytheclipse-storage-test.txt") + .await + .unwrap(); } } diff --git a/crates/mytheclipse-storage/src/s3.rs b/crates/mytheclipse-storage/src/s3.rs index e327053..7c38f9f 100644 --- a/crates/mytheclipse-storage/src/s3.rs +++ b/crates/mytheclipse-storage/src/s3.rs @@ -52,7 +52,8 @@ impl S3Storage { access_key: &str, secret_key: &str, ) -> Self { - let credentials = Credentials::new(access_key, secret_key, None, None, "mytheclipse-storage"); + let credentials = + Credentials::new(access_key, secret_key, None, None, "mytheclipse-storage"); let config = aws_sdk_s3::Config::builder() .region(Region::new(region.to_string())) .endpoint_url(endpoint) @@ -322,13 +323,19 @@ mod tests { .await; storage - .put("mytheclipse-storage-test.txt", bytes_stream(b"hello s3".to_vec())) + .put( + "mytheclipse-storage-test.txt", + bytes_stream(b"hello s3".to_vec()), + ) .await .unwrap(); let data = read_to_vec(storage.get("mytheclipse-storage-test.txt").await.unwrap()) .await .unwrap(); assert_eq!(data, b"hello s3"); - storage.delete("mytheclipse-storage-test.txt").await.unwrap(); + storage + .delete("mytheclipse-storage-test.txt") + .await + .unwrap(); } }