@@ -6,11 +6,9 @@ use std::collections::HashMap;
66use std:: fmt:: Debug ;
77use std:: sync:: Arc ;
88use tracing:: trace;
9-
10- use crate :: {
11- config:: Config ,
12- evaluate:: { EvalDetail , Repository } ,
13- } ;
9+ #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
10+ use crate :: sync:: SyncType ;
11+ use crate :: { config:: Config , evaluate:: { EvalDetail , Repository } } ;
1412use crate :: { sync:: Synchronizer , FPConfig } ;
1513use crate :: { sync:: UpdateCallback , user:: FPUser } ;
1614use crate :: { FPDetail , SdkAuthorization , Toggle } ;
@@ -248,6 +246,18 @@ impl FeatureProbe {
248246 syncer. start_sync ( self . config . start_wait , self . should_stop . clone ( ) ) ;
249247 }
250248
249+ #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
250+ pub fn sync_once ( & self , t : SyncType ) {
251+ trace ! ( "sync now url {}" , & self . config. toggles_url) ;
252+ let syncer = match & self . syncer {
253+ Some ( syncer) => syncer. clone ( ) ,
254+ None => return ,
255+ } ;
256+ tokio:: spawn ( async move {
257+ syncer. sync_now ( t) . await . expect ( "sync once error" ) ;
258+ } ) ;
259+ }
260+
251261 #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
252262 fn connect_socket ( & mut self ) {
253263 let mut slf = self . clone ( ) ;
@@ -297,7 +307,6 @@ impl FeatureProbe {
297307
298308 #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
299309 fn socket_on_update ( slf : Self , payload : Option < socketio_rs:: Payload > ) -> SocketCallback {
300- use crate :: sync:: SyncType ;
301310
302311 trace ! ( "socket_on_update: {:?}" , payload) ;
303312 async move {
0 commit comments