@@ -377,6 +377,94 @@ def kill_split(self, split_name, default_treatment, change_number):
377377 self ._split_synchronizers .split_sync .kill_split (split_name , default_treatment ,
378378 change_number )
379379
380+ class RedisSynchronizer (BaseSynchronizer ):
381+ """Redis Synchronizer."""
382+
383+ def __init__ (self , split_synchronizers , split_tasks ):
384+ """
385+ Class constructor.
386+
387+ :param split_synchronizers: syncs for performing synchronization of segments and splits
388+ :type split_synchronizers: splitio.sync.synchronizer.SplitSynchronizers
389+ :param split_tasks: tasks for starting/stopping tasks
390+ :type split_tasks: splitio.sync.synchronizer.SplitTasks
391+ """
392+ self ._split_synchronizers = split_synchronizers
393+ self ._split_tasks = split_tasks
394+
395+ def sync_all (self ):
396+ """
397+ Not implemented
398+ """
399+ pass
400+
401+ def shutdown (self , blocking ):
402+ """
403+ Stop tasks.
404+
405+ :param blocking:flag to wait until tasks are stopped
406+ :type blocking: bool
407+ """
408+ _LOGGER .debug ('Shutting down tasks.' )
409+ self .stop_periodic_data_recording (blocking )
410+
411+ def start_periodic_data_recording (self ):
412+ """Start recorders."""
413+ _LOGGER .debug ('Starting periodic data recording' )
414+ self ._split_tasks .impressions_count_task .start ()
415+ if self ._split_tasks .unique_keys_task is not None :
416+ self ._split_tasks .unique_keys_task .start ()
417+ if self ._split_tasks .clear_filter_task is not None :
418+ self ._split_tasks .clear_filter_task .start ()
419+
420+ def stop_periodic_data_recording (self , blocking ):
421+ """
422+ Stop recorders.
423+
424+ :param blocking: flag to wait until tasks are stopped
425+ :type blocking: bool
426+ """
427+ _LOGGER .debug ('Stopping periodic data recording' )
428+ if blocking :
429+ events = []
430+ tasks = [self ._split_tasks .impressions_count_task ]
431+ if self ._split_tasks .unique_keys_task is not None :
432+ tasks .append (self ._split_tasks .unique_keys_task )
433+ if self ._split_tasks .clear_filter_task is not None :
434+ tasks .append (self ._split_tasks .clear_filter_task )
435+ for task in tasks :
436+ stop_event = threading .Event ()
437+ task .stop (stop_event )
438+ events .append (stop_event )
439+ if all (event .wait () for event in events ):
440+ _LOGGER .debug ('all tasks finished successfully.' )
441+ else :
442+ self ._split_tasks .impressions_count_task .stop ()
443+ if self ._split_tasks .unique_keys_task is not None :
444+ self ._split_tasks .unique_keys_task .stop ()
445+ if self ._split_tasks .clear_filter_task is not None :
446+ self ._split_tasks .clear_filter_task .stop ()
447+
448+ def kill_split (self , split_name , default_treatment , change_number ):
449+ """Kill a split locally."""
450+ raise NotImplementedError ()
451+
452+ def synchronize_splits (self , till ):
453+ """Synchronize all splits."""
454+ raise NotImplementedError ()
455+
456+ def synchronize_segment (self , segment_name , till ):
457+ """Synchronize particular segment."""
458+ raise NotImplementedError ()
459+
460+ def start_periodic_fetching (self ):
461+ """Start fetchers for splits and segments."""
462+ raise NotImplementedError ()
463+
464+ def stop_periodic_fetching (self ):
465+ """Stop fetchers for splits and segments."""
466+ raise NotImplementedError ()
467+
380468class LocalhostSynchronizer (BaseSynchronizer ):
381469 """LocalhostSynchronizer."""
382470
0 commit comments