@@ -7,6 +7,7 @@ edition = "2021"
|
||||
crunch-envelope.workspace = true
|
||||
crunch-in-memory = { workspace = true, optional = true }
|
||||
crunch-traits.workspace = true
|
||||
crunch-nats = {workspace = true,optional = true}
|
||||
|
||||
anyhow.workspace = true
|
||||
tracing.workspace = true
|
||||
@@ -21,6 +22,7 @@ futures.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["in-memory", "traits"]
|
||||
default = ["in-memory", "traits", "nats"]
|
||||
traits = []
|
||||
in-memory = ["dep:crunch-in-memory"]
|
||||
in-memory = ["dep:crunch-in-memory"]
|
||||
nats = ["dep:crunch-nats"]
|
@@ -20,6 +20,11 @@ pub use publisher::Publisher;
|
||||
pub use subscriber::Subscriber;
|
||||
pub use transport::Transport;
|
||||
|
||||
#[cfg(feature = "nats")]
|
||||
pub mod nats {
|
||||
pub use crunch_nats::{NatsConnectCredentials, NatsConnectOptions};
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Crunch {
|
||||
publisher: Publisher,
|
||||
@@ -74,6 +79,15 @@ pub mod builder {
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(feature = "nats")]
|
||||
pub async fn with_nats_transport(
|
||||
&mut self,
|
||||
options: crate::nats::NatsConnectOptions<'_>,
|
||||
) -> Result<&mut Self, crunch_traits::errors::TransportError> {
|
||||
self.transport = Some(Transport::nats(options).await?);
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn with_outbox(&mut self, enabled: bool) -> &mut Self {
|
||||
self.outbox_enabled = enabled;
|
||||
self
|
||||
|
@@ -14,6 +14,15 @@ impl Transport {
|
||||
crunch_in_memory::InMemoryTransport::default(),
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(feature = "nats")]
|
||||
pub async fn nats(
|
||||
options: crate::nats::NatsConnectOptions<'_>,
|
||||
) -> Result<Self, crunch_traits::errors::TransportError> {
|
||||
Ok(Self(std::sync::Arc::new(
|
||||
crunch_nats::NatsTransport::new(options).await?,
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DynTransport> for Transport {
|
||||
|
Reference in New Issue
Block a user