-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
550 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye, bookworm | ||
ARG VARIANT="bookworm" | ||
FROM mcr.microsoft.com/devcontainers/rust:1-${VARIANT} | ||
|
||
# Include lld linker to improve build times either by using environment variable | ||
# RUSTFLAGS="-C link-arg=-fuse-ld=lld" or with Cargo's configuration file (i.e see .cargo/config.toml). | ||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install clang lld \ | ||
&& apt-get autoremove -y && apt-get clean -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/rust-postgres | ||
{ | ||
"name": "Deadpool", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/workspace", | ||
|
||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"lldb.executable": "/usr/bin/lldb", | ||
// VS Code don't watch files under ./target | ||
"files.watcherExclude": { | ||
"**/target/**": true | ||
}, | ||
"rust-analyzer.checkOnSave.command": "clippy" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"vadimcn.vscode-lldb", | ||
"mutantdino.resourcemonitor", | ||
"rust-lang.rust-analyzer", | ||
"tamasfe.even-better-toml", | ||
"serayuzgur.crates", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [5432], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "rustc --version", | ||
|
||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
version: "3.8" | ||
|
||
volumes: | ||
postgres-data: | ||
redis-data: | ||
redis-cluster-data: | ||
rabbitmq-data: | ||
|
||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
# Use the VARIANT arg to pick a Debian OS version: buster, bullseye, bookworm | ||
# Use bullseye when on local on arm64/Apple Silicon. | ||
VARIANT: bookworm | ||
env_file: | ||
# Ensure that the variables in .env match the same variables in devcontainer.json | ||
- .env | ||
# Security Opt and cap_add for C++ based debuggers to work. | ||
# See `runArgs`: https://github.com/Microsoft/vscode-docs/blob/main/docs/remote/devcontainerjson-reference.md | ||
# security_opt: | ||
# - seccomp:unconfined | ||
# cap_add: | ||
# - SYS_PTRACE | ||
|
||
volumes: | ||
- ..:/workspace:cached | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. | ||
#network_mode: service:postgres | ||
|
||
# Uncomment the next line to use a non-root user for all processes. | ||
# user: vscode | ||
|
||
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
|
||
postgres: | ||
image: postgres:15-alpine | ||
restart: unless-stopped | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
env_file: | ||
- postgres.env | ||
|
||
redis: | ||
image: redis:7.2-alpine | ||
restart: unless-stopped | ||
volumes: | ||
- redis-data:/data | ||
|
||
redis-cluster: | ||
image: grokzen/redis-cluster:7.0.10 | ||
restart: unless-stopped | ||
volumes: | ||
- redis-cluster-data:/redis-data | ||
|
||
rabbitmq: | ||
image: rabbitmq:3.12-alpine | ||
env_file: | ||
- rabbitmq.env | ||
volumes: | ||
- rabbitmq-data:/var/lib/rabbitmq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POSTGRES_PASSWORD=deadpool | ||
POSTGRES_USER=deadpool | ||
POSTGRES_DB=deadpool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RABBITMQ_DEFAULT_USER=deadpool | ||
RABBITMQ_DEFAULT_PASS=deadpool | ||
RABBITMQ_DEFAULT_VHOST=deadpool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[package] | ||
name = "deadpool" | ||
version = "0.9.5" | ||
version = "0.10.0" | ||
edition = "2018" | ||
resolver = "2" | ||
authors = ["Michael P. Jung <[email protected]>"] | ||
description = "Dead simple async pool" | ||
keywords = ["async", "database", "pool"] | ||
license = "MIT/Apache-2.0" | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/bikeshedder/deadpool" | ||
readme = "README.md" | ||
|
||
|
@@ -23,7 +23,7 @@ rt_async-std_1 = ["deadpool-runtime/async-std_1"] | |
|
||
[dependencies] | ||
num_cpus = "1.11.1" | ||
retain_mut ="0.1.6" | ||
retain_mut = "0.1.6" | ||
# `managed` feature | ||
async-trait = { version = "0.1.17", optional = true } | ||
# `serde` feature | ||
|
@@ -38,9 +38,14 @@ tokio = { version = "1.0", features = ["sync"] } | |
[dev-dependencies] | ||
async-std = { version = "1.0", features = ["attributes"] } | ||
config = { version = "0.13", features = ["json"] } | ||
criterion = { version = "0.3.4", features = ["html_reports", "async_tokio"] } | ||
itertools = "0.10.3" | ||
tokio = { version = "1.5.0", features = ["macros", "rt", "rt-multi-thread", "time"] } | ||
criterion = { version = "0.5.1", features = ["html_reports", "async_tokio"] } | ||
itertools = "0.11.0" | ||
tokio = { version = "1.5.0", features = [ | ||
"macros", | ||
"rt", | ||
"rt-multi-thread", | ||
"time", | ||
] } | ||
|
||
[[bench]] | ||
name = "managed" | ||
|
@@ -62,5 +67,5 @@ members = [ | |
"runtime", | ||
"sqlite", | ||
"sync", | ||
"examples/*" | ||
"examples/*", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[package] | ||
name = "deadpool-diesel" | ||
version = "0.4.1" | ||
version = "0.5.0" | ||
edition = "2018" | ||
resolver = "2" | ||
authors = ["Michael P. Jung <[email protected]>"] | ||
description = "Dead simple async pool for diesel" | ||
keywords = ["async", "database", "pool", "diesel"] | ||
license = "MIT/Apache-2.0" | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/bikeshedder/deadpool" | ||
readme = "README.md" | ||
|
||
|
@@ -24,8 +24,10 @@ rt_async-std_1 = ["deadpool/rt_async-std_1"] | |
serde = ["deadpool/serde"] | ||
|
||
[dependencies] | ||
deadpool = { path = "../", version = "0.9.1", default-features = false, features = ["managed"] } | ||
deadpool-sync = { path = "../sync", version = "0.1.0" } | ||
deadpool = { path = "../", version = "0.10.0", default-features = false, features = [ | ||
"managed", | ||
] } | ||
deadpool-sync = { path = "../sync", version = "0.1.1" } | ||
diesel = { version = "2.0.0", default-features = false } | ||
|
||
[dev-dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "example-diesel" | ||
version = "0.0.0" | ||
edition = "2018" | ||
resolver = "2" | ||
authors = ["Michael P. Jung <[email protected]>"] | ||
publish = false | ||
|
||
[dependencies] | ||
actix-web = "4.0.1" | ||
anyhow = "1.0.65" | ||
config = "0.13" | ||
deadpool = { version = "0.10", path = "../.." } | ||
deadpool-diesel = { version = "0.5.0", path = "../../diesel", features = [ | ||
"postgres", | ||
] } | ||
diesel = { version = "2.0.0", features = ["postgres", "chrono"] } | ||
dotenvy = "0.15" | ||
serde = { version = "1.0", features = ["derive"] } | ||
thiserror = "1.0" | ||
tokio = { version = "1", features = ["rt-multi-thread", "macros"] } | ||
tokio-postgres = { version = "0.7", features = ["with-uuid-1"] } | ||
uuid = { version = "1", features = ["serde"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use deadpool_diesel::postgres::{BuildError, Manager, Pool}; | ||
|
||
use deadpool_diesel::Runtime; | ||
|
||
use std::env; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
|
||
pub enum PoolError { | ||
#[error("unable to load .env file")] | ||
Env(dotenvy::Error), | ||
|
||
#[error("missing DATABASE_URL")] | ||
DatabaseURL, | ||
|
||
#[error("unable to build pool")] | ||
PoolBuildError(BuildError), | ||
} | ||
|
||
pub fn set_up_pool() -> Result<Pool, PoolError> { | ||
dotenvy::dotenv().map_err(PoolError::Env)?; | ||
|
||
let database_url = env::var("DATABASE_URL").map_err(|_| PoolError::DatabaseURL)?; | ||
|
||
let manager = Manager::new(database_url, Runtime::Tokio1); | ||
|
||
let pool = Pool::builder(manager) | ||
.max_size(8) | ||
.build() | ||
.map_err(PoolError::PoolBuildError)?; | ||
|
||
Ok(pool) | ||
} | ||
|
||
pub fn main() {} |
Oops, something went wrong.