mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
make segmented changelog manager a facet
Summary: The repo factory is the place where we have all elements needed for instantiating a segmented changelog manager. Let's add that as an option. It's going to be useful for some specialized binaries that don't just want to query the segmented changelog but want to understand what version of SC do we currently store an to be able to reload SC at will. Reviewed By: quark-zju Differential Revision: D35744722 fbshipit-source-id: 37f9dc4b5750b48212be1bffbdae189341fb2a06
This commit is contained in:
parent
073e1a5da8
commit
d8e7842410
@ -76,7 +76,10 @@ use repo_identity::{ArcRepoIdentity, RepoIdentity};
|
||||
use repo_permission_checker::{ArcRepoPermissionChecker, ProdRepoPermissionChecker};
|
||||
use requests_table::{ArcLongRunningRequestsQueue, SqlLongRunningRequestsQueue};
|
||||
use scuba_ext::MononokeScubaSampleBuilder;
|
||||
use segmented_changelog::{new_server_segmented_changelog, SegmentedChangelogSqlConnections};
|
||||
use segmented_changelog::{
|
||||
new_server_segmented_changelog, new_server_segmented_changelog_manager,
|
||||
ArcSegmentedChangelogManager, SegmentedChangelogSqlConnections,
|
||||
};
|
||||
use segmented_changelog_types::ArcSegmentedChangelog;
|
||||
use skiplist::{ArcSkiplistIndex, SkiplistIndex};
|
||||
use slog::o;
|
||||
@ -493,6 +496,9 @@ pub enum RepoFactoryError {
|
||||
#[error("Error opening segmented changelog")]
|
||||
SegmentedChangelog,
|
||||
|
||||
#[error("Error starting segmented changelog manager")]
|
||||
SegmentedChangelogManager,
|
||||
|
||||
#[error("Missing cache pool: {0}")]
|
||||
MissingCachePool(String),
|
||||
|
||||
@ -803,6 +809,35 @@ impl RepoFactory {
|
||||
Ok(Arc::new(segmented_changelog))
|
||||
}
|
||||
|
||||
pub async fn segmented_changelog_manager(
|
||||
&self,
|
||||
repo_config: &ArcRepoConfig,
|
||||
repo_identity: &ArcRepoIdentity,
|
||||
changeset_fetcher: &ArcChangesetFetcher,
|
||||
bookmarks: &ArcBookmarks,
|
||||
repo_blobstore: &ArcRepoBlobstore,
|
||||
) -> Result<ArcSegmentedChangelogManager> {
|
||||
let sql_connections = self
|
||||
.open::<SegmentedChangelogSqlConnections>(&repo_config.storage_config.metadata)
|
||||
.await
|
||||
.context(RepoFactoryError::SegmentedChangelog)?;
|
||||
let pool = self.maybe_volatile_pool("segmented_changelog")?;
|
||||
let manager = new_server_segmented_changelog_manager(
|
||||
self.env.fb,
|
||||
&self.ctx(Some(repo_identity)),
|
||||
repo_identity,
|
||||
repo_config.segmented_changelog_config.clone(),
|
||||
sql_connections,
|
||||
changeset_fetcher.clone(),
|
||||
bookmarks.clone(),
|
||||
repo_blobstore.clone(),
|
||||
pool,
|
||||
)
|
||||
.await
|
||||
.context(RepoFactoryError::SegmentedChangelogManager)?;
|
||||
Ok(Arc::new(manager))
|
||||
}
|
||||
|
||||
pub fn repo_derived_data(
|
||||
&self,
|
||||
repo_identity: &ArcRepoIdentity,
|
||||
|
@ -26,6 +26,7 @@ changeset_fetcher = { version = "0.1.0", path = "../blobrepo/changeset_fetcher"
|
||||
changesets = { version = "0.1.0", path = "../changesets" }
|
||||
cloned = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
|
||||
context = { version = "0.1.0", path = "../server/context" }
|
||||
facet = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
|
||||
fbinit = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
|
||||
futures = { version = "0.3.13", features = ["async-await", "compat"] }
|
||||
futures_ext = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
|
||||
|
@ -47,10 +47,12 @@ pub use segmented_changelog_types::{
|
||||
};
|
||||
|
||||
pub use crate::builder::{
|
||||
new_server_segmented_changelog, new_test_segmented_changelog, SegmentedChangelogSqlConnections,
|
||||
new_server_segmented_changelog, new_server_segmented_changelog_manager,
|
||||
new_test_segmented_changelog, SegmentedChangelogSqlConnections,
|
||||
};
|
||||
pub use crate::clone_hints::CloneHints;
|
||||
pub use crate::copy::copy_segmented_changelog;
|
||||
pub use crate::manager::{ArcSegmentedChangelogManager, SegmentedChangelogManager};
|
||||
pub use crate::tailer::SegmentedChangelogTailer;
|
||||
pub use crate::update::{seedheads_from_config, SeedHead};
|
||||
|
||||
|
@ -37,6 +37,7 @@ pub enum SegmentedChangelogType {
|
||||
Owned,
|
||||
}
|
||||
|
||||
#[facet::facet]
|
||||
pub struct SegmentedChangelogManager {
|
||||
repo_id: RepositoryId,
|
||||
sc_version_store: SegmentedChangelogVersionStore,
|
||||
|
Loading…
Reference in New Issue
Block a user