@@ -113,7 +113,7 @@ struct Inner {
113113 // process on the connection. Keep a local process_id -> session registry so
114114 // we can turn those connection-global notifications into process wakeups
115115 // without making notifications the source of truth for output delivery.
116- sessions : ArcSwap < HashMap < String , Arc < SessionState > > > ,
116+ sessions : ArcSwap < HashMap < ProcessId , Arc < SessionState > > > ,
117117 // ArcSwap makes reads cheap on the hot notification path, but writes still
118118 // need serialization so concurrent register/remove operations do not
119119 // overwrite each other's copy-on-write updates.
@@ -225,29 +225,32 @@ impl ExecServerClient {
225225
226226 pub async fn write (
227227 & self ,
228- process_id : & str ,
228+ process_id : & ProcessId ,
229229 chunk : Vec < u8 > ,
230230 ) -> Result < WriteResponse , ExecServerError > {
231231 self . inner
232232 . client
233233 . call (
234234 EXEC_WRITE_METHOD ,
235235 & WriteParams {
236- process_id : process_id. to_string ( ) ,
236+ process_id : process_id. clone ( ) ,
237237 chunk : chunk. into ( ) ,
238238 } ,
239239 )
240240 . await
241241 . map_err ( Into :: into)
242242 }
243243
244- pub async fn terminate ( & self , process_id : & str ) -> Result < TerminateResponse , ExecServerError > {
244+ pub async fn terminate (
245+ & self ,
246+ process_id : & ProcessId ,
247+ ) -> Result < TerminateResponse , ExecServerError > {
245248 self . inner
246249 . client
247250 . call (
248251 EXEC_TERMINATE_METHOD ,
249252 & TerminateParams {
250- process_id : process_id. to_string ( ) ,
253+ process_id : process_id. clone ( ) ,
251254 } ,
252255 )
253256 . await
@@ -330,20 +333,20 @@ impl ExecServerClient {
330333
331334 pub ( crate ) async fn register_session (
332335 & self ,
333- process_id : & str ,
336+ process_id : & ProcessId ,
334337 ) -> Result < Session , ExecServerError > {
335338 let state = Arc :: new ( SessionState :: new ( ) ) ;
336339 self . inner
337340 . insert_session ( process_id, Arc :: clone ( & state) )
338341 . await ?;
339342 Ok ( Session {
340343 client : self . clone ( ) ,
341- process_id : process_id. to_string ( ) . into ( ) ,
344+ process_id : process_id. clone ( ) ,
342345 state,
343346 } )
344347 }
345348
346- pub ( crate ) async fn unregister_session ( & self , process_id : & str ) {
349+ pub ( crate ) async fn unregister_session ( & self , process_id : & ProcessId ) {
347350 self . inner . remove_session ( process_id) . await ;
348351 }
349352
@@ -487,7 +490,7 @@ impl Session {
487490 match self
488491 . client
489492 . read ( ReadParams {
490- process_id : self . process_id . to_string ( ) ,
493+ process_id : self . process_id . clone ( ) ,
491494 after_seq,
492495 max_bytes,
493496 wait_ms,
@@ -519,13 +522,13 @@ impl Session {
519522}
520523
521524impl Inner {
522- fn get_session ( & self , process_id : & str ) -> Option < Arc < SessionState > > {
525+ fn get_session ( & self , process_id : & ProcessId ) -> Option < Arc < SessionState > > {
523526 self . sessions . load ( ) . get ( process_id) . cloned ( )
524527 }
525528
526529 async fn insert_session (
527530 & self ,
528- process_id : & str ,
531+ process_id : & ProcessId ,
529532 session : Arc < SessionState > ,
530533 ) -> Result < ( ) , ExecServerError > {
531534 let _sessions_write_guard = self . sessions_write_lock . lock ( ) . await ;
@@ -536,12 +539,12 @@ impl Inner {
536539 ) ) ) ;
537540 }
538541 let mut next_sessions = sessions. as_ref ( ) . clone ( ) ;
539- next_sessions. insert ( process_id. to_string ( ) , session) ;
542+ next_sessions. insert ( process_id. clone ( ) , session) ;
540543 self . sessions . store ( Arc :: new ( next_sessions) ) ;
541544 Ok ( ( ) )
542545 }
543546
544- async fn remove_session ( & self , process_id : & str ) -> Option < Arc < SessionState > > {
547+ async fn remove_session ( & self , process_id : & ProcessId ) -> Option < Arc < SessionState > > {
545548 let _sessions_write_guard = self . sessions_write_lock . lock ( ) . await ;
546549 let sessions = self . sessions . load ( ) ;
547550 let session = sessions. get ( process_id) . cloned ( ) ;
@@ -552,7 +555,7 @@ impl Inner {
552555 session
553556 }
554557
555- async fn take_all_sessions ( & self ) -> HashMap < String , Arc < SessionState > > {
558+ async fn take_all_sessions ( & self ) -> HashMap < ProcessId , Arc < SessionState > > {
556559 let _sessions_write_guard = self . sessions_write_lock . lock ( ) . await ;
557560 let sessions = self . sessions . load ( ) ;
558561 let drained_sessions = sessions. as_ref ( ) . clone ( ) ;
@@ -640,6 +643,7 @@ mod tests {
640643
641644 use super :: ExecServerClient ;
642645 use super :: ExecServerClientConnectOptions ;
646+ use crate :: ProcessId ;
643647 use crate :: connection:: JsonRpcConnection ;
644648 use crate :: protocol:: EXEC_EXITED_METHOD ;
645649 use crate :: protocol:: EXEC_OUTPUT_DELTA_METHOD ;
@@ -718,12 +722,14 @@ mod tests {
718722 . await
719723 . expect ( "client should connect" ) ;
720724
725+ let noisy_process_id = ProcessId :: from ( "noisy" ) ;
726+ let quiet_process_id = ProcessId :: from ( "quiet" ) ;
721727 let _noisy_session = client
722- . register_session ( "noisy" )
728+ . register_session ( & noisy_process_id )
723729 . await
724730 . expect ( "noisy session should register" ) ;
725731 let quiet_session = client
726- . register_session ( "quiet" )
732+ . register_session ( & quiet_process_id )
727733 . await
728734 . expect ( "quiet session should register" ) ;
729735 let mut quiet_wake_rx = quiet_session. subscribe_wake ( ) ;
@@ -734,7 +740,7 @@ mod tests {
734740 method : EXEC_OUTPUT_DELTA_METHOD . to_string ( ) ,
735741 params : Some (
736742 serde_json:: to_value ( ExecOutputDeltaNotification {
737- process_id : "noisy" . to_string ( ) ,
743+ process_id : noisy_process_id . clone ( ) ,
738744 seq,
739745 stream : ExecOutputStream :: Stdout ,
740746 chunk : b"x" . to_vec ( ) . into ( ) ,
@@ -751,7 +757,7 @@ mod tests {
751757 method : EXEC_EXITED_METHOD . to_string ( ) ,
752758 params : Some (
753759 serde_json:: to_value ( ExecExitedNotification {
754- process_id : "quiet" . to_string ( ) ,
760+ process_id : quiet_process_id ,
755761 seq : 1 ,
756762 exit_code : 17 ,
757763 } )
0 commit comments