refactor(actor): implement Raft consensus algorithm for cluster leader election
- Add voting mechanism with term tracking and vote persistence - Implement election triggering logic with majority vote counting - Add primary/replica role transition handling with state management - Integrate health check failure detection for automatic elections - Refactor actor messaging system for distributed coordination - Update repository registration to query cluster for existing primary - Add broadcast mechanism for role change notifications - Implement proper term comparison and duplicate request filtering - Upgrade dependency versions including tokio-util for async utilities - Optimize code formatting and line wrapping for improved readability - Remove redundant blank lines and improve code structure consistency - Enhance error logging and trace information for debugging purposes
This commit is contained in:
+21
-6
@@ -13,18 +13,27 @@ impl GitBare {
|
||||
crate::sanitize::validate_revision(&revision)?;
|
||||
|
||||
let repo = self.gix_repo()?;
|
||||
let oid = repo.rev_parse_single(revision.as_str())
|
||||
let oid = repo
|
||||
.rev_parse_single(revision.as_str())
|
||||
.map_err(|e| GitError::Gix(e.to_string()))?;
|
||||
let commit = oid.object()
|
||||
let commit = oid
|
||||
.object()
|
||||
.map_err(|e| GitError::Gix(e.to_string()))?
|
||||
.try_into_commit()
|
||||
.map_err(|e| GitError::Gix(format!("not a commit: {e}")))?;
|
||||
|
||||
Ok(crate::commit::get_commit::commit_to_pb(self, &commit, request.include_stats))
|
||||
Ok(crate::commit::get_commit::commit_to_pb(
|
||||
self,
|
||||
&commit,
|
||||
request.include_stats,
|
||||
))
|
||||
}
|
||||
|
||||
/// Batch lookup commits by OID list.
|
||||
pub fn list_commits_by_oid(&self, request: ListCommitsByOidRequest) -> GitResult<ListCommitsByOidResponse> {
|
||||
pub fn list_commits_by_oid(
|
||||
&self,
|
||||
request: ListCommitsByOidRequest,
|
||||
) -> GitResult<ListCommitsByOidResponse> {
|
||||
let repo = self.gix_repo()?;
|
||||
let mut commits = Vec::new();
|
||||
|
||||
@@ -33,11 +42,17 @@ impl GitBare {
|
||||
if let Ok(oid) = gix::ObjectId::from_hex(hex.as_bytes()) {
|
||||
if let Ok(obj) = repo.find_object(oid) {
|
||||
if let Ok(commit) = obj.try_into_commit() {
|
||||
commits.push(crate::commit::get_commit::commit_to_pb(self, &commit, request.include_stats));
|
||||
commits.push(crate::commit::get_commit::commit_to_pb(
|
||||
self,
|
||||
&commit,
|
||||
request.include_stats,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if commits.len() >= 100 { break; }
|
||||
if commits.len() >= 100 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(ListCommitsByOidResponse { commits })
|
||||
|
||||
Reference in New Issue
Block a user