@@ -7,6 +7,8 @@ use std::fmt::Debug;
77use std:: sync:: Arc ;
88use tracing:: trace;
99
10+ #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
11+ use crate :: sync:: SyncType ;
1012use crate :: {
1113 config:: Config ,
1214 evaluate:: { EvalDetail , Repository } ,
@@ -248,6 +250,18 @@ impl FeatureProbe {
248250 syncer. start_sync ( self . config . start_wait , self . should_stop . clone ( ) ) ;
249251 }
250252
253+ #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
254+ pub fn sync_once ( & self , t : SyncType ) {
255+ trace ! ( "sync now url {}" , & self . config. toggles_url) ;
256+ let syncer = match & self . syncer {
257+ Some ( syncer) => syncer. clone ( ) ,
258+ None => return ,
259+ } ;
260+ tokio:: spawn ( async move {
261+ syncer. sync_now ( t) . await . expect ( "sync once error" ) ;
262+ } ) ;
263+ }
264+
251265 #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
252266 fn connect_socket ( & mut self ) {
253267 let mut slf = self . clone ( ) ;
@@ -297,8 +311,6 @@ impl FeatureProbe {
297311
298312 #[ cfg( all( feature = "use_tokio" , feature = "realtime" ) ) ]
299313 fn socket_on_update ( slf : Self , payload : Option < socketio_rs:: Payload > ) -> SocketCallback {
300- use crate :: sync:: SyncType ;
301-
302314 trace ! ( "socket_on_update: {:?}" , payload) ;
303315 async move {
304316 if let Some ( syncer) = & slf. syncer {
0 commit comments