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:
+40
-9
@@ -4,7 +4,10 @@ use crate::pb::*;
|
||||
|
||||
impl GitBare {
|
||||
/// Find changed paths between two revisions (no diff content).
|
||||
pub fn find_changed_paths(&self, request: FindChangedPathsRequest) -> GitResult<FindChangedPathsResponse> {
|
||||
pub fn find_changed_paths(
|
||||
&self,
|
||||
request: FindChangedPathsRequest,
|
||||
) -> GitResult<FindChangedPathsResponse> {
|
||||
crate::sanitize::validate_revision(&request.base)?;
|
||||
crate::sanitize::validate_revision(&request.head)?;
|
||||
|
||||
@@ -41,21 +44,49 @@ impl GitBare {
|
||||
|
||||
for line in stdout.lines() {
|
||||
let line = line.trim();
|
||||
if line.is_empty() { continue; }
|
||||
if line.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let parts: Vec<&str> = line.split('\t').collect();
|
||||
if parts.is_empty() { continue; }
|
||||
if parts.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let status_str = parts[0];
|
||||
let status_letter = status_str.chars().next().unwrap_or('M');
|
||||
|
||||
let (status, old_path, new_path) = match status_letter {
|
||||
'A' => (changed_path::Status::ChangedPathStatusAdded as i32, String::new(), parts.get(1).cloned().unwrap_or_default().to_string()),
|
||||
'D' => (changed_path::Status::ChangedPathStatusDeleted as i32, parts.get(1).cloned().unwrap_or_default().to_string(), String::new()),
|
||||
'R' => (changed_path::Status::ChangedPathStatusRenamed as i32, parts.get(1).cloned().unwrap_or_default().to_string(), parts.get(2).cloned().unwrap_or_default().to_string()),
|
||||
'C' => (changed_path::Status::ChangedPathStatusCopied as i32, parts.get(1).cloned().unwrap_or_default().to_string(), parts.get(2).cloned().unwrap_or_default().to_string()),
|
||||
'T' => (changed_path::Status::ChangedPathStatusTypeChanged as i32, String::new(), parts.get(1).cloned().unwrap_or_default().to_string()),
|
||||
_ => (changed_path::Status::ChangedPathStatusModified as i32, String::new(), parts.get(1).cloned().unwrap_or_default().to_string()),
|
||||
'A' => (
|
||||
changed_path::Status::ChangedPathStatusAdded as i32,
|
||||
String::new(),
|
||||
parts.get(1).cloned().unwrap_or_default().to_string(),
|
||||
),
|
||||
'D' => (
|
||||
changed_path::Status::ChangedPathStatusDeleted as i32,
|
||||
parts.get(1).cloned().unwrap_or_default().to_string(),
|
||||
String::new(),
|
||||
),
|
||||
'R' => (
|
||||
changed_path::Status::ChangedPathStatusRenamed as i32,
|
||||
parts.get(1).cloned().unwrap_or_default().to_string(),
|
||||
parts.get(2).cloned().unwrap_or_default().to_string(),
|
||||
),
|
||||
'C' => (
|
||||
changed_path::Status::ChangedPathStatusCopied as i32,
|
||||
parts.get(1).cloned().unwrap_or_default().to_string(),
|
||||
parts.get(2).cloned().unwrap_or_default().to_string(),
|
||||
),
|
||||
'T' => (
|
||||
changed_path::Status::ChangedPathStatusTypeChanged as i32,
|
||||
String::new(),
|
||||
parts.get(1).cloned().unwrap_or_default().to_string(),
|
||||
),
|
||||
_ => (
|
||||
changed_path::Status::ChangedPathStatusModified as i32,
|
||||
String::new(),
|
||||
parts.get(1).cloned().unwrap_or_default().to_string(),
|
||||
),
|
||||
};
|
||||
|
||||
paths.push(ChangedPath {
|
||||
|
||||
Reference in New Issue
Block a user