feat(gateway): implement remote service forwarding for distributed git operations
- Add remote client functions for archive, blame, and branch services - Implement fallback logic to forward requests to remote storage nodes - Add logging for forwarding operations with route details - Update Cargo.lock with new dependencies including ractor cluster libraries - Extend .gitignore with IDE and build system files - Remove outdated comments from bare repository implementation
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use gitks::server::serve;
|
||||
use gitks::actor::init_actor_cluster;
|
||||
use gitks::server::{serve, GitksService};
|
||||
|
||||
const DEFAULT_HOST: &str = "0.0.0.0";
|
||||
const DEFAULT_PORT: &str = "50051";
|
||||
const DEFAULT_STORAGE_NAME: &str = "default";
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
dotenvy::dotenv().ok();
|
||||
tracing_subscriber::fmt::init();
|
||||
tracing_subscriber::fmt().init();
|
||||
|
||||
tracing::info!(
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
@@ -17,6 +19,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let host = std::env::var("GITKS_HOST").unwrap_or_else(|_| DEFAULT_HOST.into());
|
||||
let port = std::env::var("GITKS_PORT").unwrap_or_else(|_| DEFAULT_PORT.into());
|
||||
let storage_name = std::env::var("STORAGE_NAME").unwrap_or_else(|_| DEFAULT_STORAGE_NAME.into());
|
||||
let grpc_addr = std::env::var("GITKS_ADVERTISE_ADDR")
|
||||
.unwrap_or_else(|_| format!("http://{host}:{port}"));
|
||||
|
||||
let repo_prefix = std::env::var("REPO_PREFIX_PATH")
|
||||
.map_err(|_| "REPO_PREFIX_PATH environment variable is required (e.g. /data/repos)")?;
|
||||
@@ -25,21 +30,28 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
return Err("REPO_PREFIX_PATH must be an absolute path".into());
|
||||
}
|
||||
if !repo_prefix.exists() {
|
||||
tracing::info!(
|
||||
path = %repo_prefix.display(),
|
||||
"creating repo prefix directory"
|
||||
);
|
||||
tracing::info!(path = %repo_prefix.display(), "creating repo prefix directory");
|
||||
std::fs::create_dir_all(&repo_prefix)?;
|
||||
}
|
||||
|
||||
let addr: std::net::SocketAddr = format!("{host}:{port}").parse()?;
|
||||
let actor_svc = GitksService::new(repo_prefix.clone());
|
||||
let (node_actor, node_handle) = init_actor_cluster(
|
||||
actor_svc,
|
||||
storage_name.clone(),
|
||||
grpc_addr.clone(),
|
||||
).await?;
|
||||
let svc = GitksService::new(repo_prefix.clone()).with_actor(node_actor.clone());
|
||||
|
||||
tracing::info!(
|
||||
"starting gitks gRPC server on {addr}, repo prefix: {}",
|
||||
"starting gitks gRPC server on {addr}, repo prefix: {}, storage: {storage_name}, advertise: {grpc_addr}",
|
||||
repo_prefix.display()
|
||||
);
|
||||
|
||||
serve(addr, repo_prefix).await?;
|
||||
serve(addr, svc).await?;
|
||||
|
||||
node_actor.stop(None);
|
||||
node_handle.await?;
|
||||
|
||||
tracing::info!("gitks shut down");
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user