Skip to content

Commit

Permalink
Add factory constructors for git ref content mapping facet
Browse files Browse the repository at this point in the history
Summary: We would need this facet in the repo definition for Mononoke Git server so we need to add factory constructors for it which this diff does.

Reviewed By: mitrandir77

Differential Revision: D66651008

fbshipit-source-id: 7ced915b60117d7bfb0abbcc104f6c240db54900
  • Loading branch information
RajivTS authored and facebook-github-bot committed Dec 5, 2024
1 parent 1833426 commit a689d52
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions eden/mononoke/repo_factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fbinit = { version = "0.2.0", git = "https://github.com/facebookexperimental/rus
filenodes = { version = "0.1.0", path = "../filenodes" }
filestore = { version = "0.1.0", path = "../filestore" }
futures_watchdog = { version = "0.1.0", path = "../common/futures_watchdog" }
git_ref_content_mapping = { version = "0.1.0", path = "../git_ref_content_mapping" }
git_source_of_truth = { version = "0.1.0", path = "../git_source_of_truth" }
git_symbolic_refs = { version = "0.1.0", path = "../git_symbolic_refs" }
hook_manager = { version = "0.1.0", path = "../repo_attributes/hook_manager/hook_manager" }
Expand Down
19 changes: 19 additions & 0 deletions eden/mononoke/repo_factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ use filenodes::ArcFilenodes;
use filestore::ArcFilestoreConfig;
use filestore::FilestoreConfig;
use futures_watchdog::WatchdogExt;
use git_ref_content_mapping::ArcGitRefContentMapping;
use git_ref_content_mapping::SqlGitRefContentMappingBuilder;
use git_source_of_truth::ArcGitSourceOfTruthConfig;
use git_source_of_truth::SqlGitSourceOfTruthConfigBuilder;
use git_symbolic_refs::ArcGitSymbolicRefs;
Expand Down Expand Up @@ -778,6 +780,9 @@ pub enum RepoFactoryError {
#[error("Error opening bonsai-tag mapping")]
BonsaiTagMapping,

#[error("Error opening git-ref-content mapping")]
GitRefContentMapping,

#[error("Error opening git-symbolic-refs")]
GitSymbolicRefs,

Expand Down Expand Up @@ -1031,6 +1036,20 @@ impl RepoFactory {
Ok(Arc::new(bonsai_tag_mapping))
}

pub async fn git_ref_content_mapping(
&self,
repo_config: &ArcRepoConfig,
repo_identity: &ArcRepoIdentity,
) -> Result<ArcGitRefContentMapping> {
let git_ref_content_mapping = self
.open_sql::<SqlGitRefContentMappingBuilder>(repo_config)
.await
.context(RepoFactoryError::GitRefContentMapping)?
.build(repo_identity.id());
// TODO(rajshar): Add caching for git_ref_content_mapping
Ok(Arc::new(git_ref_content_mapping))
}

pub async fn git_symbolic_refs(
&self,
repo_config: &ArcRepoConfig,
Expand Down
1 change: 1 addition & 0 deletions eden/mononoke/repo_factory/test_repo_factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ facet = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust
fbinit = { version = "0.2.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
filenodes = { version = "0.1.0", path = "../../filenodes" }
filestore = { version = "0.1.0", path = "../../filestore" }
git_ref_content_mapping = { version = "0.1.0", path = "../../git_ref_content_mapping" }
git_source_of_truth = { version = "0.1.0", path = "../../git_source_of_truth" }
git_symbolic_refs = { version = "0.1.0", path = "../../git_symbolic_refs" }
hook_manager = { version = "0.1.0", path = "../../repo_attributes/hook_manager/hook_manager" }
Expand Down
14 changes: 14 additions & 0 deletions eden/mononoke/repo_factory/test_repo_factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ use fbinit::FacebookInit;
use filenodes::ArcFilenodes;
use filestore::ArcFilestoreConfig;
use filestore::FilestoreConfig;
use git_ref_content_mapping::ArcGitRefContentMapping;
use git_ref_content_mapping::SqlGitRefContentMappingBuilder;
use git_source_of_truth::ArcGitSourceOfTruthConfig;
use git_source_of_truth::SqlGitSourceOfTruthConfigBuilder;
use git_symbolic_refs::ArcGitSymbolicRefs;
Expand Down Expand Up @@ -489,6 +491,18 @@ impl TestRepoFactory {
))
}

/// Construct Git Ref Content Mapping using the in-memory metadata
/// database.
pub fn git_ref_content_mapping(
&self,
repo_identity: &ArcRepoIdentity,
) -> Result<ArcGitRefContentMapping> {
Ok(Arc::new(
SqlGitRefContentMappingBuilder::from_sql_connections(self.metadata_db.clone())
.build(repo_identity.id()),
))
}

/// Construct Repo Metadata Checkpoint using the in-memory metadata
pub fn repo_metadata_checkpoint(
&self,
Expand Down

0 comments on commit a689d52

Please sign in to comment.