summaryrefslogtreecommitdiff
path: root/crates/system_action/action_macros/src
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-10-13 13:34:39 +0800
committer魏曹先生 <1992414357@qq.com>2025-10-13 13:34:39 +0800
commit67fb8ec01b351c6c9fd2af321166bb92250b1218 (patch)
tree4509509ef932e1009dcd2da25928fcff71a5f29b /crates/system_action/action_macros/src
parent860fb317bca61ce66a2c98df933aa666dae0a43f (diff)
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
Diffstat (limited to 'crates/system_action/action_macros/src')
-rw-r--r--crates/system_action/action_macros/src/lib.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/system_action/action_macros/src/lib.rs b/crates/system_action/action_macros/src/lib.rs
index 683efcb..aa1c696 100644
--- a/crates/system_action/action_macros/src/lib.rs
+++ b/crates/system_action/action_macros/src/lib.rs
@@ -67,14 +67,19 @@ fn generate_action_struct(input_fn: ItemFn, _is_local: bool) -> proc_macro2::Tok
ctx: action_system::action::ActionContext,
#arg_param_name: #arg_type
) -> Result<#return_type, tcp_connection::error::TcpTargetError> {
- pool.process::<#arg_type, #return_type>(
+ let args_json = serde_json::to_string(&#arg_param_name)
+ .map_err(|e| {
+ tcp_connection::error::TcpTargetError::Serialization(e.to_string())
+ })?;
+ let result_json = pool.process_json(
Box::leak(string_proc::snake_case!(stringify!(#action_name_ident)).into_boxed_str()),
ctx,
- serde_json::to_string(&#arg_param_name)
- .map_err(|e| {
- tcp_connection::error::TcpTargetError::Serialization(e.to_string())
- })?
- ).await
+ args_json,
+ ).await?;
+ serde_json::from_str(&result_json)
+ .map_err(|e| {
+ tcp_connection::error::TcpTargetError::Serialization(e.to_string())
+ })
}
#[allow(dead_code)]