mirror of
https://github.com/facebook/sapling.git
synced 2024-10-16 11:52:02 +03:00
640f272598
Summary: Migrate the configuration of sql data managers from the old configuration using `sql_ext::SqlConstructors` to the new configuration using `sql_construct::SqlConstruct`. In the old configuration, sharded filenodes were included in the configuration of remote databases, even when that made no sense: ``` [storage.db.remote] db_address = "main_database" sharded_filenodes = { shard_map = "sharded_database", shard_num = 100 } [storage.blobstore.multiplexed] queue_db = { remote = { db_address = "queue_database", sharded_filenodes = { shard_map = "valid_config_but_meaningless", shard_num = 100 } } ``` This change separates out: * **DatabaseConfig**, which describes a single local or remote connection to a database, used in configuration like the queue database. * **MetadataDatabaseConfig**, which describes the multiple databases used for repo metadata. **MetadataDatabaseConfig** is either: * **Local**, which is a local sqlite database, the same as for **DatabaseConfig**; or * **Remote**, which contains: * `primary`, the database used for main metadata. * `filenodes`, the database used for filenodes, which may be sharded or unsharded. More fields can be added to **RemoteMetadataDatabaseConfig** when we want to add new databases. New configuration looks like: ``` [storage.metadata.remote] primary = { db_address = "main_database" } filenodes = { sharded = { shard_map = "sharded_database", shard_num = 100 } } [storage.blobstore.multiplexed] queue_db = { remote = { db_address = "queue_database" } } ``` The `sql_construct` crate facilitates this by providing the following traits: * **SqlConstruct** defines the basic rules for construction, and allows construction based on a local sqlite database. * **SqlShardedConstruct** defines the basic rules for construction based on sharded databases. * **FbSqlConstruct** and **FbShardedSqlConstruct** allow construction based on unsharded and sharded remote databases on Facebook infra. * **SqlConstructFromDatabaseConfig** allows construction based on the database defined in **DatabaseConfig**. * **SqlConstructFromMetadataDatabaseConfig** allows construction based on the appropriate database defined in **MetadataDatabaseConfig**. * **SqlShardableConstructFromMetadataDatabaseConfig** allows construction based on the appropriate shardable databases defined in **MetadataDatabaseConfig**. Sql database managers should implement: * **SqlConstruct** in order to define how to construct an unsharded instance from a single set of `SqlConnections`. * **SqlShardedConstruct**, if they are shardable, in order to define how to construct a sharded instance. * If the database is part of the repository metadata database config, either of: * **SqlConstructFromMetadataDatabaseConfig** if they are not shardable. By default they will use the primary metadata database, but this can be overridden by implementing `remote_database_config`. * **SqlShardableConstructFromMetadataDatabaseConfig** if they are shardable. They must implement `remote_database_config` to specify where to get the sharded or unsharded configuration from. Reviewed By: StanislavGlebik Differential Revision: D20734883 fbshipit-source-id: bb2f4cb3806edad2bbd54a47558a164e3190c5d1
50 lines
2.0 KiB
TOML
50 lines
2.0 KiB
TOML
[package]
|
|
name = "bonsai_hg_mapping"
|
|
edition = "2018"
|
|
version = "0.1.0"
|
|
authors = ['Facebook']
|
|
license = "GPLv2+"
|
|
include = ["schemas/**/*.sql", "src/**/*.rs", "test/**/*.rs"]
|
|
|
|
[lib]
|
|
path = "src/lib.rs"
|
|
|
|
[[test]]
|
|
name = "bonsai_hg_mapping_test"
|
|
path = "test/main.rs"
|
|
|
|
[dependencies]
|
|
bonsai_hg_mapping_entry_thrift = { path = "if" }
|
|
caching_ext = { path = "../common/rust/caching_ext" }
|
|
context = { path = "../server/context" }
|
|
mercurial_types = { path = "../mercurial/types" }
|
|
mononoke_types = { path = "../mononoke_types" }
|
|
sql_construct = { path = "../common/sql_construct" }
|
|
sql_ext = { path = "../common/rust/sql_ext" }
|
|
bytes_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
cachelib = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
cloned = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
fbinit = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
fbthrift = { git = "https://github.com/facebook/fbthrift.git", branch = "master" }
|
|
futures_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
memcache = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
sql = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
stats = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
abomonation = "0.7"
|
|
abomonation_derive = "0.5"
|
|
anyhow = "1.0"
|
|
bytes = { version = "0.5", features = ["serde"] }
|
|
futures-old = { package = "futures", version = "0.1" }
|
|
heapsize = "0.4"
|
|
heapsize_derive = "0.1"
|
|
thiserror = "1.0"
|
|
tokio = "0.1"
|
|
tokio-compat = "0.1"
|
|
|
|
[dev-dependencies]
|
|
mercurial_types-mocks = { path = "../mercurial/types/mocks" }
|
|
mononoke_types-mocks = { path = "../mononoke_types/mocks" }
|
|
async_unit = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
|
assert_matches = "1.3"
|
|
futures = { version = "0.3", features = ["async-await", "compat"] }
|