@@ -483,17 +483,17 @@ impl III {
483483 Ok ( Trigger :: new ( unregister_fn) )
484484 }
485485
486- pub async fn call (
486+ pub async fn trigger (
487487 & self ,
488488 function_id : & str ,
489489 data : impl serde:: Serialize ,
490490 ) -> Result < Value , IIIError > {
491491 let value = serde_json:: to_value ( data) ?;
492- self . call_with_timeout ( function_id, value, DEFAULT_TIMEOUT )
492+ self . trigger_with_timeout ( function_id, value, DEFAULT_TIMEOUT )
493493 . await
494494 }
495495
496- pub async fn call_with_timeout (
496+ pub async fn trigger_with_timeout (
497497 & self ,
498498 function_id : & str ,
499499 data : Value ,
@@ -527,7 +527,7 @@ impl III {
527527 }
528528 }
529529
530- pub fn call_void < TInput > ( & self , function_id : & str , data : TInput ) -> Result < ( ) , IIIError >
530+ pub fn trigger_void < TInput > ( & self , function_id : & str , data : TInput ) -> Result < ( ) , IIIError >
531531 where
532532 TInput : Serialize ,
533533 {
@@ -544,10 +544,34 @@ impl III {
544544 } )
545545 }
546546
547+ pub async fn call (
548+ & self ,
549+ function_id : & str ,
550+ data : impl serde:: Serialize ,
551+ ) -> Result < Value , IIIError > {
552+ self . trigger ( function_id, data) . await
553+ }
554+
555+ pub fn call_void < TInput > ( & self , function_id : & str , data : TInput ) -> Result < ( ) , IIIError >
556+ where
557+ TInput : Serialize ,
558+ {
559+ self . trigger_void ( function_id, data)
560+ }
561+
562+ pub async fn call_with_timeout (
563+ & self ,
564+ function_id : & str ,
565+ data : Value ,
566+ timeout : Duration ,
567+ ) -> Result < Value , IIIError > {
568+ self . trigger_with_timeout ( function_id, data, timeout) . await
569+ }
570+
547571 /// List all registered functions from the engine
548572 pub async fn list_functions ( & self ) -> Result < Vec < FunctionInfo > , IIIError > {
549573 let result = self
550- . call ( "engine::functions::list" , serde_json:: json!( { } ) )
574+ . trigger ( "engine::functions::list" , serde_json:: json!( { } ) )
551575 . await ?;
552576
553577 let functions = result
@@ -642,7 +666,7 @@ impl III {
642666 /// List all connected workers from the engine
643667 pub async fn list_workers ( & self ) -> Result < Vec < WorkerInfo > , IIIError > {
644668 let result = self
645- . call ( "engine::workers::list" , serde_json:: json!( { } ) )
669+ . trigger ( "engine::workers::list" , serde_json:: json!( { } ) )
646670 . await ?;
647671
648672 let workers = result
@@ -656,7 +680,7 @@ impl III {
656680 /// List all registered triggers from the engine
657681 pub async fn list_triggers ( & self ) -> Result < Vec < TriggerInfo > , IIIError > {
658682 let result = self
659- . call ( "engine::triggers::list" , serde_json:: json!( { } ) )
683+ . trigger ( "engine::triggers::list" , serde_json:: json!( { } ) )
660684 . await ?;
661685
662686 let triggers = result
@@ -670,7 +694,7 @@ impl III {
670694 /// Register this worker's metadata with the engine (called automatically on connect)
671695 fn register_worker_metadata ( & self ) {
672696 if let Some ( metadata) = self . inner . worker_metadata . lock_or_recover ( ) . clone ( ) {
673- let _ = self . call_void ( "engine::workers::register" , metadata) ;
697+ let _ = self . trigger_void ( "engine::workers::register" , metadata) ;
674698 }
675699 }
676700
@@ -1112,7 +1136,7 @@ mod tests {
11121136 async fn invoke_function_times_out_and_clears_pending ( ) {
11131137 let iii = III :: new ( "ws://localhost:1234" ) ;
11141138 let result = iii
1115- . call_with_timeout (
1139+ . trigger_with_timeout (
11161140 "functions.echo" ,
11171141 json ! ( { "a" : 1 } ) ,
11181142 Duration :: from_millis ( 10 ) ,
0 commit comments