mySQL backend implementation

This commit is contained in:
mdecimus
2023-12-01 07:49:12 +01:00
parent 5f36e1f356
commit 4a00bbb79e
20 changed files with 1856 additions and 33 deletions

View File

@@ -137,12 +137,15 @@ future-release = [ { if = "authenticated-as", ne = "", then = "99999999d"},
{ else = false } ]
[store.db]
#path = "{TMP}/sqlite.db"
#path = "PATH/sqlite.db"
host = "localhost"
port = 5432
#port = 5432
port = 3307
database = "stalwart"
user = "postgres"
password = "mysecretpassword"
#user = "postgres"
#password = "mysecretpassword"
user = "root"
password = "password"
[store.blob]
type = "local"

View File

@@ -135,12 +135,15 @@ future-release = [ { if = "authenticated-as", ne = "", then = "99999999d"},
{ else = false } ]
[store.db]
path = "{TMP}/sqlite.db"
#path = "PATH/sqlite.db"
host = "localhost"
port = 5432
#port = 5432
port = 3307
database = "stalwart"
user = "postgres"
password = "mysecretpassword"
#user = "postgres"
#password = "mysecretpassword"
user = "root"
password = "password"
[store.blob]
type = "local"

View File

@@ -22,7 +22,9 @@
*/
use store::{
backend::{fs::FsStore, postgres::PostgresStore, s3::S3Store, sqlite::SqliteStore},
backend::{
fs::FsStore, mysql::MysqlStore, postgres::PostgresStore, s3::S3Store, sqlite::SqliteStore,
},
write::{blob::BlobQuota, now, BatchBuilder, BlobOp, F_CLEAR},
BlobClass, BlobHash, BlobStore, Store,
};
@@ -46,12 +48,15 @@ path = "{TMP}"
const CONFIG_DB: &str = r#"
[store.db]
path = "{TMP}/db.db?mode=rwc"
#path = "PATH/sqlite.db"
host = "localhost"
post = 5432
#port = 5432
port = 3307
database = "stalwart"
user = "postgres"
password = "mysecretpassword"
#user = "postgres"
#password = "mysecretpassword"
user = "root"
password = "password"
"#;
@@ -76,8 +81,9 @@ pub async fn blob_tests() {
// Init store
//let store: Store = SqliteStore::open(
let store: Store = PostgresStore::open(
//let store: Store = FdbStore::open(
//let store: Store = FdbStore::open(
//let store: Store = PostgresStore::open(
let store: Store = MysqlStore::open(
&Config::new(&CONFIG_DB.replace("{TMP}", temp_dir.path.as_path().to_str().unwrap()))
.unwrap(),
)

View File

@@ -29,7 +29,9 @@ use std::io::Read;
use ::store::Store;
use store::backend::{foundationdb::FdbStore, postgres::PostgresStore, sqlite::SqliteStore};
use store::backend::{
foundationdb::FdbStore, mysql::MysqlStore, postgres::PostgresStore, sqlite::SqliteStore,
};
use utils::config::Config;
pub struct TempDir {
@@ -44,10 +46,13 @@ local.path = "PATH"
[store.db]
#path = "PATH/sqlite.db"
host = "localhost"
post = 5432
#port = 5432
port = 3307
database = "stalwart"
user = "postgres"
password = "mysecretpassword"
#user = "postgres"
#password = "mysecretpassword"
user = "root"
password = "password"
"#;
@@ -58,14 +63,15 @@ pub async fn store_tests() {
let config_file = CONFIG.replace("PATH", &temp_dir.path.to_string_lossy());
//let db: Store = SqliteStore::open(&Config::new(&config_file).unwrap())
//let db: Store = FdbStore::open(&Config::new(&config_file).unwrap())
let db: Store = PostgresStore::open(&Config::new(&config_file).unwrap())
//let db: Store = PostgresStore::open(&Config::new(&config_file).unwrap())
let db: Store = MysqlStore::open(&Config::new(&config_file).unwrap())
.await
.unwrap()
.into();
if insert {
db.destroy().await;
}
query::test(db.clone(), insert).await;
//query::test(db.clone(), insert).await;
assign_id::test(db).await;
temp_dir.delete();
}