-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up and extract database into crate
- Loading branch information
Showing
18 changed files
with
142 additions
and
136 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -15,6 +15,8 @@ If possible, encrypt your message with our PGP key; | |
- **Public key**: https://keys.openpgp.org/[email protected] | ||
|
||
|
||
It is also possible to report it via the [Github security page](https://github.com/photos-network/core/security) | ||
|
||
Please do not make vulnerabilities public without notifying us and giving us at least 4 weeks to respond. | ||
|
||
If you are going to write about Photos.network’s security, please get in touch, so we can make sure that all claims are correct. |
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,20 @@ | ||
[package] | ||
name = "database" | ||
version.workspace = true | ||
authors.workspace = true | ||
description.workspace = true | ||
homepage.workspace = true | ||
documentation.workspace = true | ||
repository.workspace = true | ||
readme.workspace = true | ||
license.workspace = true | ||
edition.workspace = true | ||
|
||
[lib] | ||
name = "database" | ||
path = "src/lib.rs" | ||
doctest = false | ||
|
||
[dependencies] | ||
async-trait = { workspace = true } | ||
sea-orm = { workspace = true, features = ["sqlx-postgres", "runtime-tokio-rustls", "mock"] } |
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,15 @@ | ||
# database | ||
|
||
This crate provides an database abstraction used within [Photos.network](https://photos.network). | ||
|
||
## Framework choice | ||
|
||
The decision for [sea-orm](https://www.sea-ql.org/SeaORM/) has 3 main reasons compared to [Diesel](https://diesel.rs/) | ||
|
||
- supports async | ||
- testable | ||
- written in rust | ||
|
||
A big downsite of sea-orm: | ||
|
||
- performance |
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
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,27 +1,5 @@ | ||
use std::time::Duration; | ||
|
||
use log::LevelFilter; | ||
use sea_orm::{ConnectOptions, Database, DatabaseConnection, DbErr}; | ||
|
||
pub mod error; | ||
pub mod exif_info; | ||
pub mod file; | ||
pub mod location; | ||
pub mod media_item; | ||
|
||
pub async fn open_db_conn(db_url: String) -> std::result::Result<DatabaseConnection, DbErr> { | ||
let mut opt = ConnectOptions::new(db_url); | ||
opt.max_connections(100) | ||
.min_connections(5) | ||
.connect_timeout(Duration::from_secs(8)) | ||
.acquire_timeout(Duration::from_secs(8)) | ||
.idle_timeout(Duration::from_secs(8)) | ||
.max_lifetime(Duration::from_secs(8)) | ||
.sqlx_logging(true) | ||
.sqlx_logging_level(LevelFilter::Info); | ||
// .set_schema_search_path("my_schema".into()); // Setting default PostgreSQL schema | ||
|
||
let db = Database::connect(opt).await?; | ||
|
||
Ok(db) | ||
} |
Oops, something went wrong.