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

fix misspelled function names #12

Merged
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
16 changes: 13 additions & 3 deletions src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ where
}
}

pub async fn aquire(&self) -> Result<RedisPoolConnection<C>, RedisPoolError> {
pub async fn acquire(&self) -> Result<RedisPoolConnection<C>, RedisPoolError> {
let permit = match &self.sem {
Some(sem) => Some(sem.clone().acquire_owned().await?),
None => None,
};
let con = self.aquire_connection().await?;
let con = self.acquire_connection().await?;
Ok(RedisPoolConnection::new(con, permit, self.queue.clone()))
}

async fn aquire_connection(&self) -> RedisResult<C> {
async fn acquire_connection(&self) -> RedisResult<C> {
while let Some(mut con) = self.queue.pop() {
let res = redis::Pipeline::with_capacity(2)
.cmd("UNWATCH")
Expand All @@ -69,6 +69,16 @@ where
self.factory.create().await
}

#[deprecated(since = "0.5.0", note = "Please use `acquire` instead")]
pub async fn aquire(&self) -> Result<RedisPoolConnection<C>, RedisPoolError> {
self.acquire().await
}

#[deprecated(since = "0.5.0", note = "Please use `acquire_connection` instead")]
async fn aquire_connection(&self) -> RedisResult<C> {
self.acquire_connection().await
}

pub fn factory(&self) -> &F {
&self.factory
}
Expand Down
4 changes: 2 additions & 2 deletions tests/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub async fn test_simple_get_set_series() -> anyhow::Result<()> {
let pool = RedisPool::from(cluster.client());

for i in 0..1000 {
let mut con = pool.aquire().await?;
let mut con = pool.acquire().await?;
let (value,) = redis::Pipeline::with_capacity(2)
.set(i, i)
.ignore()
Expand Down Expand Up @@ -53,7 +53,7 @@ pub async fn test_simple_get_set_parrallel() -> anyhow::Result<()> {

async fn get_set_byte_array(i: usize, pool: &ClusterRedisPool) -> anyhow::Result<Vec<u8>> {
let mut con = pool
.aquire()
.acquire()
.await
.context("Failed to establish connection")?;

Expand Down
8 changes: 4 additions & 4 deletions tests/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub async fn test_simple_get_set_series() -> anyhow::Result<()> {
let pool = RedisPool::from(redis.client());

for i in 0..50 {
let mut con = pool.aquire().await?;
let mut con = pool.acquire().await?;
let (value,) = redis::Pipeline::with_capacity(2)
.set("test", i)
.ignore()
Expand Down Expand Up @@ -57,7 +57,7 @@ async fn get_set_byte_array_from_pool(
pool: &SingleRedisPool,
) -> anyhow::Result<Vec<u8>> {
let mut con = pool
.aquire()
.acquire()
.await
.context("Failed to establish connection")?;

Expand All @@ -81,7 +81,7 @@ pub async fn test_bad_connection_eviction() -> anyhow::Result<()> {
let docker = Cli::docker();
let redis = TestRedis::new(&docker);
let pool = RedisPool::new(ClosableConnectionFactory(redis.client()), 1, Some(1));
let mut con = pool.aquire().await.context("Failed to open connection")?;
let mut con = pool.acquire().await.context("Failed to open connection")?;

get_set_byte_array("foo", &mut con)
.await
Expand All @@ -96,7 +96,7 @@ pub async fn test_bad_connection_eviction() -> anyhow::Result<()> {

drop(con);

let mut con = pool.aquire().await.context("Failed to open connection")?;
let mut con = pool.acquire().await.context("Failed to open connection")?;

get_set_byte_array("foo", &mut con)
.await
Expand Down
Loading