mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
sharding
This commit is contained in:
parent
ce0d3ff3e4
commit
fdbc6f2e46
1 changed files with 17 additions and 7 deletions
|
|
@ -15,7 +15,7 @@ use std::convert::identity;
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Sharding;
|
pub struct Sharding;
|
||||||
|
|
||||||
const SHARDS: &[&str] = &["-1", "-2"];
|
const SHARDS: &[&str] = &["-1", "-2", "-3", "-4"];
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl ServiceTrait for Sharding {
|
impl ServiceTrait for Sharding {
|
||||||
|
|
@ -73,25 +73,35 @@ impl ServiceTrait for Sharding {
|
||||||
"table": "filecache",
|
"table": "filecache",
|
||||||
"primary_key": "fileid",
|
"primary_key": "fileid",
|
||||||
"shard_key": "storage",
|
"shard_key": "storage",
|
||||||
"companion_tables": ["filecache_extended"],
|
"companion_tables": ["filecache_extended", "files_metadata"],
|
||||||
"shards": [
|
"shards": [
|
||||||
{
|
{
|
||||||
"name": "haze",
|
"dbname": "haze",
|
||||||
"host": "db-1",
|
"host": "db-1",
|
||||||
"tableprefix": "oc_",
|
|
||||||
"user": "haze",
|
"user": "haze",
|
||||||
"password": "haze",
|
"password": "haze",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "haze",
|
"dbname": "haze",
|
||||||
"host": "db-2",
|
"host": "db-2",
|
||||||
"tableprefix": "oc_",
|
"user": "haze",
|
||||||
|
"password": "haze",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dbname": "haze",
|
||||||
|
"host": "db-3",
|
||||||
|
"user": "haze",
|
||||||
|
"password": "haze",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dbname": "haze",
|
||||||
|
"host": "db-4",
|
||||||
"user": "haze",
|
"user": "haze",
|
||||||
"password": "haze",
|
"password": "haze",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ok(hashmap! {String::from("db.sharding") => shard_config})
|
Ok(hashmap! {String::from("dbsharding") => shard_config})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue