Skip to content

Commit

Permalink
fix: merge in all Prisma fork fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
garrensmith committed Jan 21, 2023
1 parent 1d028c4 commit 354aa2b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## v0.8.0

- Forked from Mobc repo
- Replaces channels with Sempahores
- Adds metrics

## v0.7.3 2021-6-25

Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mobc"
version = "0.7.3"
authors = ["importcjj <importcjj@gmail.com>"]
version = "0.8.0"
authors = ["importcjj <importcjj@gmail.com>", "Garren Smith <garren.smith@gmail.com>"]
edition = "2018"
readme = "README.md"
license = "MIT/Apache-2.0"
Expand Down Expand Up @@ -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]]
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/metrics_utils.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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"
);
}

0 comments on commit 354aa2b

Please sign in to comment.