Skip to content
Draft
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
26 changes: 12 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/tokio-redis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ publish = false

[dependencies]
axum = { path = "../../axum" }
bb8-redis = "0.24"
bb8 = "0.9"
redis = { version = "=1.0.0-rc.4", default-features = false, features = ["tokio-comp", "bb8"] }
tokio = { version = "1.0", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
14 changes: 5 additions & 9 deletions examples/tokio-redis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ use axum::{
routing::get,
Router,
};
use bb8_redis::{
bb8::{self, Pool, PooledConnection},
redis::AsyncCommands,
RedisConnectionManager,
};
use redis::AsyncCommands;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[tokio::main]
Expand All @@ -28,8 +24,8 @@ async fn main() {
.init();

tracing::debug!("connecting to redis");
let manager = RedisConnectionManager::new("redis://localhost").unwrap();
let pool = bb8::Pool::builder().build(manager).await.unwrap();
let client = redis::Client::open("redis://localhost").unwrap();
let pool = bb8::Pool::builder().build(client).await.unwrap();

{
// ping the database before starting
Expand All @@ -56,7 +52,7 @@ async fn main() {
axum::serve(listener, app).await.unwrap();
}

type ConnectionPool = Pool<RedisConnectionManager>;
type ConnectionPool = bb8::Pool<redis::Client>;

async fn using_connection_pool_extractor(
State(pool): State<ConnectionPool>,
Expand All @@ -68,7 +64,7 @@ async fn using_connection_pool_extractor(

// we can also write a custom extractor that grabs a connection from the pool
// which setup is appropriate depends on your application
struct DatabaseConnection(PooledConnection<'static, RedisConnectionManager>);
struct DatabaseConnection(bb8::PooledConnection<'static, redis::Client>);

impl<S> FromRequestParts<S> for DatabaseConnection
where
Expand Down
Loading