Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor improvements #23

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading