From 305a95f5570d78164049474a82c54735f3d88957 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 29 Oct 2025 15:19:42 +0800 Subject: update: Action.rs 1. Rename `insert` to `with_data` and `insert_arc` to `with_arc_data` 2. Add new `insert_data` and `insert_arc_data` methods that take &mut self --- crates/vcs_actions/src/connection/action_service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/vcs_actions/src/connection/action_service.rs') diff --git a/crates/vcs_actions/src/connection/action_service.rs b/crates/vcs_actions/src/connection/action_service.rs index ca236e7..3786fc5 100644 --- a/crates/vcs_actions/src/connection/action_service.rs +++ b/crates/vcs_actions/src/connection/action_service.rs @@ -184,7 +184,7 @@ async fn process_connection(stream: TcpStream, vault: Arc, action_pool: A let ctx: ActionContext = ActionContext::remote().insert_instance(instance); // Insert vault into context - let ctx = ctx.insert_arc(vault); + let ctx = ctx.with_arc_data(vault); info!( "Process action `{}` with argument `{}`", -- cgit From b48073e4c9a2ca80dd0503efc5b6ab121d504028 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 29 Oct 2025 15:23:00 +0800 Subject: feat: Add port override capability to server entry The server_entry function now accepts an optional port_override parameter that allows specifying a custom port instead of using the configured port from vault configuration. When port_override is greater than 0, it takes precedence over the configured port. --- .../vcs_actions/src/connection/action_service.rs | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'crates/vcs_actions/src/connection/action_service.rs') diff --git a/crates/vcs_actions/src/connection/action_service.rs b/crates/vcs_actions/src/connection/action_service.rs index 3786fc5..d9ddaab 100644 --- a/crates/vcs_actions/src/connection/action_service.rs +++ b/crates/vcs_actions/src/connection/action_service.rs @@ -21,21 +21,23 @@ use crate::{ }; // Start the server with a Vault using the specified directory -pub async fn server_entry(vault_path: impl Into) -> Result<(), TcpTargetError> { +pub async fn server_entry( + vault_path: impl Into, + port_override: u16, +) -> Result<(), TcpTargetError> { // Read the vault cfg let vault_cfg = VaultConfig::read().await?; // Create TCPListener - let listener = create_tcp_listener(&vault_cfg).await?; + let listener = create_tcp_listener(&vault_cfg, port_override).await?; // Initialize the vault let vault: Arc = init_vault(vault_cfg, vault_path.into()).await?; // Lock the vault - vault.lock().map_err(|e| { - error!("{}", e); - TcpTargetError::Locked(e.to_string()) - })?; + vault + .lock() + .map_err(|e| TcpTargetError::Locked(e.to_string()))?; // Create ActionPool let action_pool: Arc = Arc::new(server_action_pool()); @@ -50,9 +52,17 @@ pub async fn server_entry(vault_path: impl Into) -> Result<(), TcpTarge Ok(()) } -async fn create_tcp_listener(cfg: &VaultConfig) -> Result { +async fn create_tcp_listener( + cfg: &VaultConfig, + port_override: u16, +) -> Result { let local_bind_addr = cfg.server_config().local_bind(); - let bind_port = cfg.server_config().port(); + let port = if port_override > 0 { + port_override // Override -> PORT > 0 + } else { + cfg.server_config().port() // Default -> Port = 0 + }; + let bind_port = port; let sock_addr = SocketAddr::new(*local_bind_addr, bind_port); let listener = TcpListener::bind(sock_addr).await?; -- cgit