Skip to content

Commit

Permalink
update bb8 to 0.8 & remove all unwrap from code
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBM committed Jul 8, 2023
1 parent 52ced4c commit ef2c835
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ readme = "README.md"
lazy_static = "1"
rand = "0.8"
radix_fmt = "1"
bb8 = "0.7"
bb8 = "0.8"
thiserror = "1"
redis = { version = "0.23", features = ["tokio-comp", "async-std-comp"] }
async-trait = "0.1"
Expand Down
17 changes: 6 additions & 11 deletions src/pooled_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ use crate::r#trait::RsmqConnection;
use crate::types::RedisBytes;
use crate::types::{RsmqMessage, RsmqOptions, RsmqQueueAttributes};
use crate::RsmqResult;
use core::convert::TryFrom;
use std::marker::PhantomData;
use std::ops::DerefMut;

use async_trait::async_trait;
use core::convert::TryFrom;
use redis::RedisError;
use std::marker::PhantomData;

#[derive(Clone, Debug)]
pub struct RedisConnectionManager {
Expand All @@ -34,11 +32,8 @@ impl bb8::ManageConnection for RedisConnectionManager {
self.client.get_async_connection().await
}

async fn is_valid(
&self,
conn: &mut bb8::PooledConnection<'_, Self>,
) -> Result<(), Self::Error> {
redis::cmd("PING").query_async(conn.deref_mut()).await
async fn is_valid(&self, conn: &mut redis::aio::Connection) -> Result<(), Self::Error> {
redis::cmd("PING").query_async(conn).await
}

fn has_broken(&self, _: &mut Self::Connection) -> bool {
Expand Down Expand Up @@ -85,7 +80,7 @@ impl PooledRsmq {
password, options.host, options.port, options.db
);

let manager = RedisConnectionManager::new(url).unwrap();
let manager = RedisConnectionManager::new(url)?;
let builder = bb8::Pool::builder();

let mut builder = if let Some(value) = pool_options.max_size {
Expand All @@ -96,7 +91,7 @@ impl PooledRsmq {

builder = builder.min_idle(pool_options.min_idle);

let pool = builder.build(manager).await.unwrap();
let pool = builder.build(manager).await?;

Ok(PooledRsmq {
pool,
Expand Down

0 comments on commit ef2c835

Please sign in to comment.