mirror of
https://github.com/rwf2/Rocket.git
synced 2025-02-16 13:42:05 +00:00
This commit makes passing compile UI tests optional, allowing the CI to succeed even when UI tests fail. This change was made because UI tests are highly susceptible to false negatives due to benign rustc compiler output changes. A failure resulting from such a benign change inhibits progress in the main branch due to failing PR testing which would have otherwise passed. |
||
---|---|---|
.. | ||
codegen | ||
lib | ||
README.md |
sync_db_pools
![docs.svg](https://img.shields.io/badge/web-master-red.svg?style=flat&label=docs&colorB=d33847)
This crate provides traits, utilities, and a procedural macro for configuring
and accessing database connection pools in Rocket. This implementation is backed
by r2d2
and exposes connections through request guards.
Usage
First, enable the feature corresponding to your database type:
[dependencies.rocket_sync_db_pools]
version = "0.1.0-rc.2"
features = ["diesel_sqlite_pool"]
A full list of supported databases and their associated feature names is
available in the crate docs. In whichever configuration source you choose,
configure a databases
dictionary with a key for each database, here
sqlite_logs
in a TOML source:
[default.databases]
sqlite_logs = { url = "/path/to/database.sqlite" }
In your application's source code:
#[macro_use] extern crate rocket;
use rocket_sync_db_pools::{database, diesel};
#[database("sqlite_logs")]
struct LogsDbConn(diesel::SqliteConnection);
#[get("/logs/<id>")]
async fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> {
conn.run(|c| Logs::by_id(c, id)).await
}
#[launch]
fn rocket() -> _ {
rocket::build().attach(LogsDbConn::fairing())
}
See the crate docs for full details.