Files
zhenyi 821537186e 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
2026-06-11 12:11:05 +08:00

32 lines
906 B
Rust

pub mod nats;
pub mod redis;
use async_trait::async_trait;
use thiserror::Error;
use tokio::sync::mpsc;
#[derive(Error, Debug)]
pub enum MessageBusError {
#[error("Redis error: {0}")]
Redis(String),
#[error("NATS error: {0}")]
Nats(String),
#[error("Connection closed")]
ConnectionClosed,
#[error("Channel not found: {0}")]
ChannelNotFound(String),
#[error("Serialization error: {0}")]
Serialization(String),
}
#[async_trait]
pub trait MessageBus: Send + Sync + 'static {
async fn publish(&self, channel: &str, message: &[u8]) -> Result<(), MessageBusError>;
async fn subscribe(&self, channel: &str) -> Result<mpsc::Receiver<Vec<u8>>, MessageBusError>;
async fn unsubscribe(&self, channel: &str) -> Result<(), MessageBusError>;
async fn close(&self) -> Result<(), MessageBusError>;
}
pub use nats::NatsMessageBus;
pub use redis::RedisMessageBus;