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

add option to use rustls instead of native-tls in shuttle-shared-db #870

Merged
merged 5 commits into from
May 9, 2023
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
22 changes: 19 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ jobs:
path:
description: "Path to crate external from workspace"
type: string
features:
description: "Features to enable"
type: string
default: --all-features
executor: docker-rust
environment:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse"
Expand All @@ -218,13 +222,13 @@ jobs:
- run: |
cargo clippy --tests \
--all-targets \
--all-features \
<< parameters.features >> \
--manifest-path << parameters.path >>/Cargo.toml \
--no-deps -- \
--D warnings \
-A clippy::let-unit-value \
-A clippy::format-push-string
- run: cargo test --all-features --manifest-path << parameters.path >>/Cargo.toml -- --nocapture
- run: cargo test << parameters.features >> --manifest-path << parameters.path >>/Cargo.toml -- --nocapture
- save-cargo-cache
platform-test:
parameters:
Expand Down Expand Up @@ -491,7 +495,6 @@ workflows:
- resources/aws-rds
- resources/persist
- resources/secrets
- resources/shared-db
- resources/static-folder
- services/shuttle-actix-web
- services/shuttle-axum
Expand All @@ -505,6 +508,18 @@ workflows:
- services/shuttle-tide
- services/shuttle-tower
- services/shuttle-warp
- check-standalone:
utterstep marked this conversation as resolved.
Show resolved Hide resolved
# shuttle-shared-db has mutually exclusive features
# so we run checks for each feature separately
name: "resources/shared-db: << matrix.features >>"
matrix:
alias: check-standalone-shared-db
parameters:
path: [resources/shared-db]
features:
- "-F mongodb"
- "-F postgres"
- "-F postgres-rustls"
- platform-test:
name: << matrix.crate >>
requires:
Expand All @@ -527,6 +542,7 @@ workflows:
requires:
- platform-test
- check-standalone
- check-standalone-shared-db
filters:
branches:
only: production
Expand Down
5 changes: 3 additions & 2 deletions resources/shared-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ async-trait = "0.1.56"
mongodb = { version = "2.3.0", optional = true }
serde = { version = "1.0.148", features = ["derive"] }
shuttle-service = { path = "../../service", version = "0.16.0", default-features = false }
sqlx = { version = "0.6.2", features = ["runtime-tokio-native-tls"], optional = true }
sqlx = { version = "0.6.2", optional = true }

[features]
postgres = ["sqlx/postgres"]
postgres = ["sqlx/postgres", "sqlx/runtime-tokio-native-tls"]
postgres-rustls = ["sqlx/postgres", "sqlx/runtime-tokio-rustls"]
10 changes: 5 additions & 5 deletions resources/shared-db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ This plugin manages databases that are shared with other services on [shuttle](h

## Usage

Add `shuttle-shared-db` to the dependencies for your service. Every type of shareable database is behind the following feature flag and attribute path
Add `shuttle-shared-db` to the dependencies for your service. Every type of shareable database is behind the following feature flag and attribute path (`*-rustls` uses rustls for TLS, the default uses native-tls).

| Engine | Feature flag | Attribute path |
|----------|--------------|-----------------------------|
| Postgres | postgres | shuttle_shared_db::Postgres |
| MongoDB | mongodb | shuttle_shared_db::MongoDb |
| Engine | Feature flags | Attribute path |
|----------|--------------------------------|-----------------------------|
| Postgres | `postgres` / `postgres-rustls` | shuttle_shared_db::Postgres |
| MongoDB | `mongodb` | shuttle_shared_db::MongoDb |

An example using the Rocket framework can be found on [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/rocket/postgres)

Expand Down
4 changes: 2 additions & 2 deletions resources/shared-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mod mongo;
#[cfg(feature = "mongodb")]
pub use mongo::MongoDb;

#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "postgres-rustls"))]
mod postgres;

#[cfg(feature = "postgres")]
#[cfg(any(feature = "postgres", feature = "postgres-rustls"))]
pub use postgres::Postgres;