Skip to content

Commit 5e5ce3d

Browse files
zainkabanidjc
authored andcommitted
Fix configuration of queue strategy
1 parent ad653e0 commit 5e5ce3d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bb8/src/api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub struct Builder<M: ManageConnection> {
103103
}
104104

105105
/// bb8's queue strategy when getting pool resources
106-
#[derive(Debug)]
106+
#[derive(Debug, Clone, Copy)]
107107
pub enum QueueStrategy {
108108
/// First in first out
109109
/// This strategy behaves like a queue

bb8/src/internals.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ where
5454
conns: VecDeque<IdleConn<M::Connection>>,
5555
num_conns: u32,
5656
pending_conns: u32,
57-
queue_strategy: QueueStrategy,
5857
}
5958

6059
impl<M> PoolInternals<M>
@@ -81,6 +80,8 @@ where
8180
self.num_conns += 1;
8281
}
8382

83+
let queue_strategy = pool.statics.queue_strategy;
84+
8485
let mut guard = InternalsGuard::new(conn, pool);
8586
while let Some(waiter) = self.waiters.pop_front() {
8687
// This connection is no longer idle, send it back out
@@ -95,7 +96,7 @@ where
9596

9697
// Queue it in the idle queue
9798
let conn = IdleConn::from(guard.conn.take().unwrap());
98-
match self.queue_strategy {
99+
match queue_strategy {
99100
QueueStrategy::Fifo => self.conns.push_back(conn),
100101
QueueStrategy::Lifo => self.conns.push_front(conn),
101102
}
@@ -180,7 +181,6 @@ where
180181
conns: VecDeque::new(),
181182
num_conns: 0,
182183
pending_conns: 0,
183-
queue_strategy: QueueStrategy::default(),
184184
}
185185
}
186186
}

0 commit comments

Comments
 (0)