refactor(tests): reformat code and update dependency management
- Reorganized import statements in adapter tests for better readability - Replaced or_insert_with(Vec::new) with or_default() in test closures - Updated Cargo.lock with new dependency versions and checksums - Added TLS features to tonic dependency configuration - Included sqlx, chrono, and uuid dependencies with specific features - Added jsonwebtoken and arc-swap as project dependencies - Reformatted assertion statements to comply with line length limits - Adjusted base64 import order in engine codec module - Updated protobuf include statement formatting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
pub mod redis;
|
||||
pub mod nats;
|
||||
pub mod redis;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use thiserror::Error;
|
||||
@@ -27,5 +27,5 @@ pub trait MessageBus: Send + Sync + 'static {
|
||||
async fn close(&self) -> Result<(), MessageBusError>;
|
||||
}
|
||||
|
||||
pub use nats::NatsMessageBus;
|
||||
pub use redis::RedisMessageBus;
|
||||
pub use nats::NatsMessageBus;
|
||||
@@ -34,7 +34,8 @@ impl MessageBus for NatsMessageBus {
|
||||
async fn subscribe(&self, channel: &str) -> Result<mpsc::Receiver<Vec<u8>>, MessageBusError> {
|
||||
let (tx, rx) = mpsc::channel::<Vec<u8>>(256);
|
||||
|
||||
let mut subscriber = self.client
|
||||
let mut subscriber = self
|
||||
.client
|
||||
.subscribe(channel.to_string())
|
||||
.await
|
||||
.map_err(|e| MessageBusError::Nats(e.to_string()))?;
|
||||
@@ -85,4 +86,4 @@ impl MessageBus for NatsMessageBus {
|
||||
self.shutdowns.clear();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ pub struct RedisMessageBus {
|
||||
|
||||
impl RedisMessageBus {
|
||||
pub async fn new(redis_url: &str) -> Result<Self, MessageBusError> {
|
||||
let config = Config::from_url(redis_url)
|
||||
.map_err(|e| MessageBusError::Redis(e.to_string()))?;
|
||||
let config =
|
||||
Config::from_url(redis_url).map_err(|e| MessageBusError::Redis(e.to_string()))?;
|
||||
|
||||
let client = Client::new(config.clone(), None, None, None);
|
||||
let subscriber = SubscriberClient::new(config, None, None, None);
|
||||
@@ -64,9 +64,8 @@ impl MessageBus for RedisMessageBus {
|
||||
|
||||
tokio::spawn(async move {
|
||||
while let Ok(message) = message_rx.recv().await {
|
||||
if &message.channel == &channel_owned {
|
||||
let data: Vec<u8> = FromValue::from_value(message.value)
|
||||
.unwrap_or_default();
|
||||
if message.channel == channel_owned {
|
||||
let data: Vec<u8> = FromValue::from_value(message.value).unwrap_or_default();
|
||||
if tx.send(data).await.is_err() {
|
||||
break;
|
||||
}
|
||||
@@ -96,4 +95,4 @@ impl MessageBus for RedisMessageBus {
|
||||
.map_err(|e| MessageBusError::Redis(e.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user