From 354aa2b57ba873273d534899430ab37babc1bdf9 Mon Sep 17 00:00:00 2001 From: Garren Date: Thu, 12 Jan 2023 20:03:27 +0200 Subject: [PATCH] fix: merge in all Prisma fork fixes --- CHANGELOG.md | 2 +- Cargo.toml | 8 ++++---- README.md | 11 +++++------ src/metrics_utils.rs | 22 +++++++++++----------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a42c87..c58baca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ## v0.8.0 -- Forked from Mobc repo - Replaces channels with Sempahores +- Adds metrics ## v0.7.3 2021-6-25 diff --git a/Cargo.toml b/Cargo.toml index 3aaa67e..32129d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mobc" -version = "0.7.3" -authors = ["importcjj "] +version = "0.8.0" +authors = ["importcjj ", "Garren Smith "] edition = "2018" readme = "README.md" license = "MIT/Apache-2.0" @@ -33,10 +33,10 @@ tracing-subscriber = "0.3.11" [dev-dependencies] tokio = { version = "1", features = ["full"] } -env_logger = "0.8" +env_logger = "0.10.0" tide = "0.16" async-std = { version = "1.0", features = ["attributes"] } -actix-web = "3" +actix-web = "4.2.1" actix-rt = "2" [[example]] diff --git a/README.md b/README.md index 8dbccff..1e56e39 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # Prisma Mobc -This is a fork of the original Mobc with fixes for stablility. This changes the design of Mobc to use -a Semaphore to manage the pool rather than the original design that used channels. - A generic connection pool with async/await support. Inspired by Deadpool, Sqlx, r2d2 and Golang SQL package. @@ -15,19 +12,21 @@ Inspired by Deadpool, Sqlx, r2d2 and Golang SQL package. ```toml [dependencies] -mobc = { git = "https://github.com/prisma/mobc", branch = "main"} +mobc = "0.8" # For async-std runtime -# mobc = { git = "https://github.com/prisma/mobc", features = ["async-std"] } +# mobc = { version = "0.8", features = ["async-std"] } # For actix-rt 1.0 -# mobc = { git = "https://github.com/prisma/mobc", features = ["actix-rt"] } +# mobc = { version = "0.8", features = ["actix-rt"] } ``` ## Features - Support async/.await syntax - Support both `tokio` and `async-std` +- Tokio metric support +- Production battle tested - High performance - Easy to customize - Dynamic configuration diff --git a/src/metrics_utils.rs b/src/metrics_utils.rs index 350d1de..58edd9d 100644 --- a/src/metrics_utils.rs +++ b/src/metrics_utils.rs @@ -1,13 +1,13 @@ use metrics::{describe_counter, describe_gauge, describe_histogram}; -pub const OPENED_TOTAL: &str = "prisma_pool_connections_opened_total"; -pub const CLOSED_TOTAL: &str = "prisma_pool_connections_closed_total"; -pub const OPEN_CONNECTIONS: &str = "prisma_pool_connections_open"; +pub const OPENED_TOTAL: &str = "mobc_pool_connections_opened_total"; +pub const CLOSED_TOTAL: &str = "mobc_pool_connections_closed_total"; +pub const OPEN_CONNECTIONS: &str = "mobc_pool_connections_open"; -pub const ACTIVE_CONNECTIONS: &str = "prisma_pool_connections_busy"; -pub const IDLE_CONNECTIONS: &str = "prisma_pool_connections_idle"; -pub const WAIT_COUNT: &str = "prisma_client_queries_wait"; -pub const WAIT_DURATION: &str = "prisma_client_queries_wait_histogram_ms"; +pub const ACTIVE_CONNECTIONS: &str = "mobc_pool_connections_busy"; +pub const IDLE_CONNECTIONS: &str = "mobc_pool_connections_idle"; +pub const WAIT_COUNT: &str = "mobc_client_queries_wait"; +pub const WAIT_DURATION: &str = "mobc_client_queries_wait_histogram_ms"; pub fn describe_metrics() { describe_counter!(OPENED_TOTAL, "Total number of Pool Connections opened"); @@ -20,21 +20,21 @@ pub fn describe_metrics() { describe_gauge!( ACTIVE_CONNECTIONS, - "Number of currently busy Pool Connections (executing a datasource query)" + "Number of currently busy Pool Connections (executing a database query)" ); describe_gauge!( IDLE_CONNECTIONS, - "Number of currently unused Pool Connections (waiting for the next datasource query to run)" + "Number of currently unused Pool Connections (waiting for the next pool query to run)" ); describe_gauge!( WAIT_COUNT, - "Number of Prisma Client queries currently waiting for a connection" + "Number of queries currently waiting for a connection" ); describe_histogram!( WAIT_DURATION, - "Histogram of the wait time of all Prisma Client Queries in ms" + "Histogram of the wait time of all queries in ms" ); }