diff --git a/Cargo.lock b/Cargo.lock index 1495cba..b1d6405 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,12 +57,6 @@ dependencies = [ "url", ] -[[package]] -name = "arcstr" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96e8a5dd56ad327e5a40d752927856e5b84a547a6ff1c6a6eedd4a7648e395a3" - [[package]] name = "arrayvec" version = "0.5.2" @@ -1733,7 +1727,6 @@ dependencies = [ name = "rustacles-brokers" version = "0.2.0" dependencies = [ - "arcstr", "deadpool-redis", "env_logger", "futures 0.3.19", diff --git a/brokers/Cargo.toml b/brokers/Cargo.toml index a869a59..b5523e4 100644 --- a/brokers/Cargo.toml +++ b/brokers/Cargo.toml @@ -11,7 +11,6 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -arcstr = "1.1" deadpool-redis = { version = "0.9", optional = true } lapin = { version = "1.1", optional = true } env_logger = "0.7" diff --git a/brokers/src/redis.rs b/brokers/src/redis.rs index 27ae227..4500cb5 100644 --- a/brokers/src/redis.rs +++ b/brokers/src/redis.rs @@ -1,9 +1,9 @@ use std::{ fmt::{self, Debug}, + sync::Arc, time::{SystemTime, UNIX_EPOCH}, }; -use arcstr::ArcStr; pub use deadpool_redis; use deadpool_redis::{ redis::{ @@ -39,9 +39,9 @@ const STREAM_TIMEOUT_KEY: &'static str = "timeout_at"; pub struct RedisBroker { /// The consumer name of this broker. Should be unique to the container/machine consuming /// messages. - pub name: ArcStr, + pub name: Arc, /// The consumer group name. - pub group: ArcStr, + pub group: Arc, /// The largest chunk to consume from Redis. This is only exposed for tuning purposes and /// doesn't affect the public API at all. pub max_chunk: usize, @@ -89,7 +89,7 @@ impl RedisBroker { } /// Creates a new broker with sensible defaults. - pub fn new(group: impl Into, pool: Pool, address: &str) -> RedisBroker { + pub fn new(group: impl Into>, pool: Pool, address: &str) -> RedisBroker { let group = group.into(); let name = nanoid!(); let read_opts = RedisBroker::make_read_opts(&*group, &name); @@ -190,7 +190,7 @@ impl RedisBroker { .iter() .copied() .map(|event| { - let event = ArcStr::from(event); + let event = Arc::::from(event); let group = group.clone(); let name = name.clone(); @@ -247,7 +247,7 @@ impl RedisBroker { let messages = read.map(|reply| reply.keys).into_iter().flatten().flat_map( move |event| { let group = group.clone(); - let key = ArcStr::from(event.key); + let key = Arc::::from(event.key); event.ids.into_iter().map(move |id| { Ok(Message::::new( id, diff --git a/brokers/src/redis/message.rs b/brokers/src/redis/message.rs index 3e3898c..0adee06 100644 --- a/brokers/src/redis/message.rs +++ b/brokers/src/redis/message.rs @@ -1,6 +1,8 @@ -use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use std::{ + sync::Arc, + time::{Duration, SystemTime, UNIX_EPOCH}, +}; -use arcstr::ArcStr; use redis::{streams::StreamId, AsyncCommands}; use serde::{de::DeserializeOwned, Serialize}; @@ -12,9 +14,9 @@ use super::{RedisBroker, STREAM_DATA_KEY, STREAM_TIMEOUT_KEY}; #[derive(Debug)] pub struct Message { /// The group this message belongs to. - pub group: ArcStr, + pub group: Arc, /// The event this message signals. - pub event: ArcStr, + pub event: Arc, /// The ID of this message (generated by Redis). pub id: String, /// The data of this message. Always present unless there is a bug with a client implementation. @@ -37,7 +39,7 @@ impl Message where V: DeserializeOwned, { - pub(crate) fn new(id: StreamId, group: ArcStr, event: ArcStr, broker: RedisBroker) -> Self { + pub(crate) fn new(id: StreamId, group: Arc, event: Arc, broker: RedisBroker) -> Self { let data = id .get(STREAM_DATA_KEY) .and_then(|data: Vec| rmp_serde::from_read_ref(&data).ok());