Skip to content

Commit

Permalink
minor improvements (#23)
Browse files Browse the repository at this point in the history
* chore: add missing PartialEq

Signed-off-by: GopherJ <[email protected]>

* feat: add new_with_pool

Signed-off-by: GopherJ <[email protected]>

* feat: export manager

Signed-off-by: GopherJ <[email protected]>

* feat: support semver versions & activate only tokio by default

Signed-off-by: GopherJ <[email protected]>

---------

Signed-off-by: GopherJ <[email protected]>
  • Loading branch information
GopherJ authored May 30, 2024
1 parent 88dcbc7 commit 21517b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ documentation = "https://docs.rs/rsmq_async/"
readme = "README.md"

[dependencies]
lazy_static = "1"
rand = "0.8"
radix_fmt = "1"
bb8 = "0.8"
thiserror = "1"
redis = { version = "0.25", features = ["tokio-comp", "async-std-comp"] }
async-trait = "0.1"
lazy_static = "^1"
rand = "^0.8"
radix_fmt = "^1"
bb8 = "^0.8"
thiserror = "^1"
redis = { version = "^0.25", default-features = false, features = ["acl", "keep-alive", "script"] }
async-trait = "^0.1"

[dev-dependencies]
net2 = "0.2"
tokio = { version = "1", features = ["rt-multi-thread"]}
net2 = "^0.2"
tokio = { version = "^1", features = ["rt-multi-thread"]}

[features]
default = ["tokio-comp", "async-std-comp"]
default = ["tokio-comp"]
tokio-comp = ["redis/tokio-comp"]
async-std-comp = ["redis/async-std-comp"]
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub type RsmqResult<T> = Result<T, RsmqError>;

/// This is the error type for any oprtation with this
/// library. It derives `ThisError`
#[derive(ThisError, Debug)]
#[derive(ThisError, Debug, PartialEq)]
pub enum RsmqError {
#[error("Pool run error: `{0:?}`")]
RunError(#[from] RunError<RedisError>),
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
//! ```rust,ignore
//!
//! impl TryFrom<RedisBytes> for String {
//!
//!
//! type Error = Vec<u8>; // Always set Error as Vec<u8>;
//!
//! fn try_from(bytes: RedisBytes) -> Result<Self, Self::Error> {
Expand All @@ -154,7 +154,7 @@ mod types;
pub use error::RsmqError;
pub use error::RsmqResult;
pub use multiplexed_facade::Rsmq;
pub use pooled_facade::{PoolOptions, PooledRsmq};
pub use pooled_facade::{PoolOptions, PooledRsmq, RedisConnectionManager};
pub use r#trait::RsmqConnection;
pub use types::RedisBytes;
pub use types::RsmqMessage;
Expand Down
15 changes: 15 additions & 0 deletions src/pooled_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ impl PooledRsmq {
},
})
}

pub fn new_with_pool(
pool: bb8::Pool<RedisConnectionManager>,
realtime: bool,
ns: Option<&str>,
) -> PooledRsmq {
PooledRsmq {
pool,
functions: RsmqFunctions {
ns: ns.unwrap_or("rsmq").to_string(),
realtime,
conn: PhantomData,
},
}
}
}

#[async_trait::async_trait]
Expand Down

0 comments on commit 21517b1

Please sign in to comment.