feat(api): extend commit and diff services with new functionality

- Add FindCommit, ListCommitsByOid, CommitIsAncestor RPCs to CommitService
- Add CheckObjectsExist, CommitsByMessage, GetCommitStats RPCs to CommitService
- Add LastCommitForPath, CountCommits, CountDivergingCommits RPCs to CommitService
- Add RawDiff, RawPatch, FindChangedPaths RPCs to DiffService
- Add FindMergeBase, WriteRef, SearchFilesByContent RPCs to RepositoryService
- Add SearchFilesByName, ObjectsSize, RepositorySize RPCs to RepositoryService
- Add FindLicense, OptimizeRepository, GetRawChanges RPCs to RepositoryService
- Add FetchRemote, CreateRepositoryFromURL RPCs to RepositoryService
- Implement server handlers for all new RPC methods
- Add new modules for commit counting, finding, and querying features
- Add new modules for diff changed paths and raw operations
- Add new modules for refs and remote operations
- Remove unnecessary comments from various source files
- Update proto definitions with new message types and service methods
This commit is contained in:
zhenyi
2026-06-08 15:37:08 +08:00
parent 8f472a0443
commit 66afd932ed
43 changed files with 3070 additions and 75 deletions
-5
View File
@@ -15,7 +15,6 @@ use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::{Arc, OnceLock};
use std::time::{Duration, Instant};
// ── Metric storage ──────────────────────────────────────────────────
struct MetricsInner {
/// Counter: total requests by (method, status_code)
@@ -62,7 +61,6 @@ fn metrics() -> &'static Arc<MetricsInner> {
})
}
// ── Duration histogram buckets (in milliseconds) ───────────────────
#[rustfmt::skip]
const DURATION_BUCKET_MS: &[u64] = &[
@@ -134,7 +132,6 @@ pub fn inc_error(kind: &str) {
.fetch_add(1, Ordering::Relaxed);
}
// ── Prometheus text format rendering ────────────────────────────────
/// Render all metrics in Prometheus text exposition format.
pub fn render_metrics() -> String {
@@ -218,7 +215,6 @@ pub fn render_metrics() -> String {
out
}
// ── HTTP server for /metrics endpoint ───────────────────────────────
/// Start the metrics HTTP server on the given port.
/// Runs in a background task; returns the JoinHandle.
@@ -265,7 +261,6 @@ async fn handle_metrics_connection(mut socket: tokio::net::TcpStream) {
let _ = socket.shutdown().await;
}
// ── Helper to wrap handler functions with metrics ───────────────────
/// A guard that records metrics on drop.
///