@@ -6,19 +6,20 @@ use futures::channel::mpsc::UnboundedReceiver;
66use futures:: stream:: { FuturesUnordered , SelectAll } ;
77use futures:: StreamExt ;
88use log:: { debug, error, warn} ;
9- use shvclient:: client :: { CallRpcMethodErrorKind , RpcCall , RpcCallDirExists , RpcCallLsList } ;
10- use shvclient:: clientnode:: { find_longest_path_prefix , METH_DIR , SIG_CHNG } ;
11- use shvclient:: { AppState , ClientEventsReceiver } ;
9+ use shvclient:: clientapi :: { CallRpcMethodErrorKind , RpcCall , RpcCallDirExists , RpcCallLsList , Subscriber } ;
10+ use shvclient:: clientnode:: { METH_DIR , SIG_CHNG } ;
11+ use shvclient:: { ClientCommandSender , ClientEventsReceiver } ;
1212use shvproto:: { DateTime , RpcValue } ;
1313use shvrpc:: rpcmessage:: { RpcError , RpcErrorCode } ;
14+ use shvrpc:: util:: find_longest_path_prefix;
1415use shvrpc:: { join_path, RpcMessageMetaTags } ;
1516use tokio:: time:: timeout;
1617
1718use crate :: alarm:: { collect_alarms, collect_state_alarms, Alarm } ;
1819use crate :: getlog:: getlog_handler;
1920use crate :: typeinfo:: TypeInfo ;
2021use crate :: util:: { subscribe, subscription_prefix_path} ;
21- use crate :: { AlarmWithTimestamp , ClientCommandSender , State , Subscriber } ;
22+ use crate :: { AlarmWithTimestamp , State } ;
2223
2324#[ derive( Clone , Copy , Debug , Default , PartialEq ) ]
2425pub ( crate ) enum SiteOnlineStatus {
@@ -202,7 +203,7 @@ async fn set_online_status(
202203 site : impl AsRef < str > ,
203204 new_status : SiteOnlineStatus ,
204205 client_commands : & ClientCommandSender ,
205- app_state : & AppState < State >
206+ app_state : & Arc < State >
206207)
207208{
208209 let site = site. as_ref ( ) ;
@@ -268,7 +269,7 @@ fn online_status_worker(
268269 site : impl Into < String > ,
269270 mut events : UnboundedReceiver < SiteOnlineStatus > ,
270271 client_commands : ClientCommandSender ,
271- app_state : AppState < State >
272+ app_state : Arc < State >
272273) -> impl Future < Output = ( ) >
273274{
274275 const ONLINE_TIMER : Duration = Duration :: from_secs ( 10 ) ;
@@ -301,7 +302,7 @@ fn online_status_worker(
301302 set_online_status ( & site, SiteOnlineStatus :: Online , & client_commands, & app_state) . await ;
302303 } else if let Err ( err) = dir_result
303304 && let CallRpcMethodErrorKind :: RpcError ( RpcError { code, .. } ) = err. error ( )
304- && ( * code == RpcErrorCode :: MethodCallTimeout || * code == RpcErrorCode :: MethodNotFound )
305+ && ( * code == RpcErrorCode :: MethodCallTimeout . into ( ) || * code == RpcErrorCode :: MethodNotFound . into ( ) )
305306 {
306307 set_online_status ( & site, SiteOnlineStatus :: Offline , & client_commands, & app_state) . await ;
307308 }
@@ -338,7 +339,7 @@ pub(crate) fn parse_notification(msg: &shvrpc::RpcMessage, sites_info: &BTreeMap
338339pub ( crate ) async fn sites_task (
339340 client_cmd_tx : ClientCommandSender ,
340341 client_evt_rx : ClientEventsReceiver ,
341- app_state : AppState < State > ,
342+ app_state : Arc < State > ,
342343)
343344{
344345 let mut client_evt_rx = client_evt_rx. fuse ( ) ;
@@ -667,11 +668,11 @@ mod tests {
667668
668669 use async_broadcast:: Sender ;
669670 use futures:: { channel:: mpsc:: { UnboundedReceiver , UnboundedSender } , StreamExt } ;
670- use shvclient:: { client :: ClientCommand , ClientEvent } ;
671+ use shvclient:: { clientapi :: ClientCommand , ClientEvent } ;
671672 use shvproto:: RpcValue ;
672673 use shvrpc:: rpcframe:: RpcFrame ;
673674
674- use crate :: { dirtylog:: DirtyLogCommand , sites:: { sites_task, SiteInfo } , sync:: SyncCommand , util:: { init_logger, testing:: { run_test, ExpectCall , ExpectSignal , ExpectSubscription , ExpectUnsubscription , PrettyJoinError , SendSignal , TestStep } , DedupReceiver } , State } ;
675+ use crate :: { dirtylog:: DirtyLogCommand , sites:: { sites_task, SiteInfo } , sync:: SyncCommand , util:: { init_logger, testing:: { run_test, ExpectCall , ExpectSignal , ExpectSubscription , ExpectUnsubscription , PrettyJoinError , SendSignal , TestStep } , DedupReceiver } } ;
675676
676677 #[ test]
677678 fn parse_notification ( ) {
@@ -731,7 +732,7 @@ mod tests {
731732
732733 #[ async_trait:: async_trait]
733734 impl TestStep < SitesTaskTestState > for ClientEvent {
734- async fn exec ( & self , _client_command_reciever : & mut UnboundedReceiver < ClientCommand < State > > , _subscriptions : & mut HashMap < String , UnboundedSender < RpcFrame > > , state : & mut SitesTaskTestState ) {
735+ async fn exec ( & self , _client_command_reciever : & mut UnboundedReceiver < ClientCommand > , _subscriptions : & mut HashMap < String , UnboundedSender < RpcFrame > > , state : & mut SitesTaskTestState ) {
735736 let x = state. sender . clone ( ) ;
736737 x. broadcast ( self . clone ( ) ) . await . expect ( "Sending ClientEvents must work" ) ;
737738 }
@@ -744,7 +745,7 @@ mod tests {
744745
745746 #[ async_trait:: async_trait]
746747 impl TestStep < SitesTaskTestState > for ExpectDirtylogCommand {
747- async fn exec ( & self , _client_command_reciever : & mut UnboundedReceiver < ClientCommand < State > > , _subscriptions : & mut HashMap < String , UnboundedSender < RpcFrame > > , state : & mut SitesTaskTestState ) {
748+ async fn exec ( & self , _client_command_reciever : & mut UnboundedReceiver < ClientCommand > , _subscriptions : & mut HashMap < String , UnboundedSender < RpcFrame > > , state : & mut SitesTaskTestState ) {
748749 let event = state. dirtylog_cmd_rx . select_next_some ( ) . await ;
749750 match ( event, self ) {
750751 ( DirtyLogCommand :: ProcessNotification ( ..) , ExpectDirtylogCommand :: ProcessNotification ) => {
@@ -765,7 +766,7 @@ mod tests {
765766
766767 #[ async_trait:: async_trait]
767768 impl TestStep < SitesTaskTestState > for ExpectSyncCommand {
768- async fn exec ( & self , _client_command_reciever : & mut UnboundedReceiver < ClientCommand < State > > , _subscriptions : & mut HashMap < String , UnboundedSender < RpcFrame > > , state : & mut SitesTaskTestState ) {
769+ async fn exec ( & self , _client_command_reciever : & mut UnboundedReceiver < ClientCommand > , _subscriptions : & mut HashMap < String , UnboundedSender < RpcFrame > > , state : & mut SitesTaskTestState ) {
769770 let Some ( event) = state. sync_cmd_rx . next ( ) . await else {
770771 panic ! ( "Expected a SyncCommand, but got none" ) ;
771772 } ;
@@ -861,7 +862,7 @@ mod tests {
861862 TestCase {
862863 name : "Empty sites" ,
863864 steps : & [
864- Box :: new ( ClientEvent :: Connected ( shvclient:: client :: ShvApiVersion :: V3 ) ) ,
865+ Box :: new ( ClientEvent :: Connected ( shvclient:: clientapi :: ShvApiVersion :: V3 ) ) ,
865866 Box :: new ( ExpectCall ( "sites" , "getSites" , Ok ( no_sites ( ) ) ) ) ,
866867 ] ,
867868 starting_files : vec ! [ ] ,
@@ -871,7 +872,7 @@ mod tests {
871872 TestCase {
872873 name : "Test everything" ,
873874 steps : & [
874- Box :: new ( ClientEvent :: Connected ( shvclient:: client :: ShvApiVersion :: V3 ) ) ,
875+ Box :: new ( ClientEvent :: Connected ( shvclient:: clientapi :: ShvApiVersion :: V3 ) ) ,
875876 Box :: new ( ExpectCall ( "sites" , "getSites" , Ok ( some_broker ( ) ) ) ) ,
876877 Box :: new ( ExpectSubscription ( "shv/legacy_sync_path_device/*:*:mntchng" . try_into ( ) . unwrap ( ) ) ) ,
877878 Box :: new ( ExpectSubscription ( "shv/node/*:*:mntchng" . try_into ( ) . unwrap ( ) ) ) ,
@@ -911,7 +912,7 @@ mod tests {
911912 TestCase {
912913 name : "Periodic sync" ,
913914 steps : & [
914- Box :: new ( ClientEvent :: Connected ( shvclient:: client :: ShvApiVersion :: V3 ) ) ,
915+ Box :: new ( ClientEvent :: Connected ( shvclient:: clientapi :: ShvApiVersion :: V3 ) ) ,
915916 Box :: new ( ExpectCall ( "sites" , "getSites" , Ok ( no_sites ( ) ) ) ) ,
916917 Box :: new ( ExpectSyncCommand :: SyncAll ) ,
917918 Box :: new ( ExpectSyncCommand :: SyncAll ) ,
0 commit comments