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

Minor lints #126

Merged
merged 1 commit into from
Jun 8, 2022
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/target/
**/*.rs.bk
Cargo.lock
*~
*~
.idea/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Crates.io](https://img.shields.io/crates/v/bb8.svg)](https://crates.io/crates/bb8)
[![Build status](https://github.com/djc/bb8/workflows/CI/badge.svg)](https://github.com/djc/bb8/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/djc/bb8/branch/main/graph/badge.svg)](https://codecov.io/gh/djc/bb8)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE-MIT)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)

A full-featured connection pool, designed for asynchronous connections (using
tokio). Originally based on [r2d2](https://github.com/sfackler/r2d2).
Expand Down
14 changes: 8 additions & 6 deletions bb8/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ impl<M: ManageConnection> Builder<M> {
/// If set, connections will be closed at the next reaping after surviving
/// past this duration.
///
/// If a connection reachs its maximum lifetime while checked out it will be
/// If a connection reaches its maximum lifetime while checked out it will be
/// closed when it is returned to the pool.
///
/// Defaults to 30 minutes.
pub fn max_lifetime(mut self, max_lifetime: Option<Duration>) -> Builder<M> {
assert!(
max_lifetime != Some(Duration::from_secs(0)),
assert_ne!(
max_lifetime,
Some(Duration::from_secs(0)),
"max_lifetime must be greater than zero!"
);
self.max_lifetime = max_lifetime;
Expand All @@ -177,8 +178,9 @@ impl<M: ManageConnection> Builder<M> {
///
/// Defaults to 10 minutes.
pub fn idle_timeout(mut self, idle_timeout: Option<Duration>) -> Builder<M> {
assert!(
idle_timeout != Some(Duration::from_secs(0)),
assert_ne!(
idle_timeout,
Some(Duration::from_secs(0)),
"idle_timeout must be greater than zero!"
);
self.idle_timeout = idle_timeout;
Expand Down Expand Up @@ -277,7 +279,7 @@ pub trait ManageConnection: Sized + Send + Sync + 'static {
/// A trait which provides functionality to initialize a connection
#[async_trait]
pub trait CustomizeConnection<C: Send + 'static, E: 'static>:
std::fmt::Debug + Send + Sync + 'static
fmt::Debug + Send + Sync + 'static
{
/// Called with connections immediately after they are returned from
/// `ManageConnection::connect`.
Expand Down
8 changes: 4 additions & 4 deletions bb8/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Mutex;
use std::task::Poll;
use std::time::Duration;
use std::{error, fmt, mem};
use std::{error, fmt};

use async_trait::async_trait;
use futures_channel::oneshot;
Expand Down Expand Up @@ -270,7 +270,7 @@ async fn test_lazy_initialization_failure() {
.build_unchecked(manager);

let res = pool.get().await;
assert_eq!(res.unwrap_err(), bb8::RunError::TimedOut);
assert_eq!(res.unwrap_err(), RunError::TimedOut);
}

#[tokio::test]
Expand Down Expand Up @@ -547,7 +547,7 @@ async fn test_conns_drop_on_pool_drop() {
.await
.unwrap();

mem::drop(pool);
drop(pool);

for _ in 0u8..10 {
if DROPPED.load(Ordering::SeqCst) == 10 {
Expand Down Expand Up @@ -741,7 +741,7 @@ async fn test_customize_connection_acquire() {

#[derive(Debug, Default)]
struct CountingCustomizer {
count: std::sync::atomic::AtomicUsize,
count: AtomicUsize,
}

#[async_trait]
Expand Down
4 changes: 1 addition & 3 deletions postgres/examples/custom_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use tokio_postgres::{Client, Error, Socket, Statement};
// docker run --name gotham-middleware-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
#[tokio::main]
async fn main() {
let config =
tokio_postgres::config::Config::from_str("postgresql://postgres:docker@localhost:5432")
.unwrap();
let config = Config::from_str("postgresql://postgres:docker@localhost:5432").unwrap();
let pg_mgr = CustomPostgresConnectionManager::new(config, tokio_postgres::NoTls);

let pool = Pool::builder()
Expand Down
2 changes: 1 addition & 1 deletion postgres/examples/hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async fn main() {

let pg_mgr = PostgresConnectionManager::new_from_stringlike(
"postgresql://postgres:mysecretpassword@localhost:5432",
tokio_postgres::NoTls,
NoTls,
)
.unwrap();

Expand Down