From e8e0b6c230f6f7efb0f5773dc49f4a5d619fdbc4 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 12 Oct 2025 18:16:18 +0800 Subject: feat: Implement SetUpstreamVaultAction - Add local action for setting upstream vault - Use action_gen macro for automatic registration - Validate action is executed locally --- crates/vcs_actions/src/actions/local_actions.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'crates/vcs_actions/src/actions') diff --git a/crates/vcs_actions/src/actions/local_actions.rs b/crates/vcs_actions/src/actions/local_actions.rs index e69de29..b230c6f 100644 --- a/crates/vcs_actions/src/actions/local_actions.rs +++ b/crates/vcs_actions/src/actions/local_actions.rs @@ -0,0 +1,17 @@ +use std::net::SocketAddr; + +use action_system::{action::ActionContext, action_gen}; +use tcp_connection::error::TcpTargetError; + +#[action_gen(local)] +pub async fn set_upstream_vault_action( + ctx: ActionContext, + upstream: SocketAddr, +) -> Result<(), TcpTargetError> { + if ctx.is_remote() { + return Err(TcpTargetError::NotLocal( + "Action was not invoked on the local machine".to_string(), + )); + } + Ok(()) +} -- cgit From 67fb8ec01b351c6c9fd2af321166bb92250b1218 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 13 Oct 2025 13:34:39 +0800 Subject: feat: Implement JSON-based type-erased action invocation - Add process_json method to ActionPool for type-agnostic calls using JSON serialization - Extend ActionContext with action_name and action_args fields and setter methods - Update action_gen macro to use process_json instead of typed process method - Implement remote action invocation framework in client_registry and action_service - Add protocol definitions for remote action communication - Enable flexible action execution without explicit type specifications --- crates/vcs_actions/src/actions/local_actions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/vcs_actions/src/actions') diff --git a/crates/vcs_actions/src/actions/local_actions.rs b/crates/vcs_actions/src/actions/local_actions.rs index b230c6f..0e210a7 100644 --- a/crates/vcs_actions/src/actions/local_actions.rs +++ b/crates/vcs_actions/src/actions/local_actions.rs @@ -6,7 +6,7 @@ use tcp_connection::error::TcpTargetError; #[action_gen(local)] pub async fn set_upstream_vault_action( ctx: ActionContext, - upstream: SocketAddr, + _upstream: SocketAddr, ) -> Result<(), TcpTargetError> { if ctx.is_remote() { return Err(TcpTargetError::NotLocal( -- cgit From acf0804b5f9bdc2796d847919a8ae20103be600a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 13 Oct 2025 14:17:51 +0800 Subject: feat: implement asynchronous action call system - Add async callback support with proper argument passing - Implement remote action invocation via TCP connection - Add hello_world_action example demonstrating async communication - Improve ActionPool with type-safe async processing - Update client registry for remote action handling - Enhance ActionContext with better instance management - Support both local and remote action execution modes --- crates/vcs_actions/src/actions/local_actions.rs | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'crates/vcs_actions/src/actions') diff --git a/crates/vcs_actions/src/actions/local_actions.rs b/crates/vcs_actions/src/actions/local_actions.rs index 0e210a7..b11a934 100644 --- a/crates/vcs_actions/src/actions/local_actions.rs +++ b/crates/vcs_actions/src/actions/local_actions.rs @@ -1,17 +1,25 @@ -use std::net::SocketAddr; - use action_system::{action::ActionContext, action_gen}; +use log::info; use tcp_connection::error::TcpTargetError; -#[action_gen(local)] -pub async fn set_upstream_vault_action( - ctx: ActionContext, - _upstream: SocketAddr, -) -> Result<(), TcpTargetError> { - if ctx.is_remote() { - return Err(TcpTargetError::NotLocal( - "Action was not invoked on the local machine".to_string(), +#[action_gen] +pub async fn hello_world_action(ctx: ActionContext, _n: ()) -> Result<(), TcpTargetError> { + // Ensure the instance is available + let Some(instance) = ctx.instance() else { + return Err(TcpTargetError::NotFound( + "Connection Instance Lost.".to_string(), )); + }; + + if ctx.is_local() { + // Invoke on local + // Send the message to the server + let _ = instance.lock().await.write_text("Hello World!").await; + } else if ctx.is_remote() { + // Read the message from the client + let read = instance.lock().await.read_text().await?; + info!("{}", read) } + Ok(()) } -- cgit