-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from AdExNetwork/bb8
Updates dependencies and adds bb8
- Loading branch information
Showing
9 changed files
with
841 additions
and
547 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
use redis::aio::SharedConnection; | ||
use redis::aio::MultiplexedConnection; | ||
use redis::RedisError; | ||
|
||
use bb8::Pool; | ||
use bb8_postgres::{ | ||
tokio_postgres::{Error as PostgresError, NoTls}, | ||
PostgresConnectionManager, | ||
}; | ||
use lazy_static::lazy_static; | ||
|
||
lazy_static! { | ||
static ref REDIS_URL: String = | ||
std::env::var("REDIS_URL").unwrap_or_else(|_| String::from("redis://127.0.0.1:6379")); | ||
static ref POSTGRES_URL: String = std::env::var("POSTGRES_URL") | ||
.unwrap_or_else(|_| String::from("postgresql://postgres:postgres@localhost:5432")); | ||
} | ||
|
||
pub async fn redis_connection() -> Result<SharedConnection, RedisError> { | ||
pub async fn redis_connection() -> Result<MultiplexedConnection, RedisError> { | ||
let client = redis::Client::open(REDIS_URL.as_str()).expect("Wrong redis connection string"); | ||
client.get_shared_async_connection().await | ||
client.get_multiplexed_tokio_connection().await | ||
} | ||
|
||
pub async fn postgres_connection() -> Result<Pool<PostgresConnectionManager<NoTls>>, PostgresError> | ||
{ | ||
let pg_mgr = PostgresConnectionManager::new_from_stringlike(POSTGRES_URL.as_str(), NoTls)?; | ||
|
||
Pool::builder().build(pg_mgr).await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters