@@ -2,8 +2,10 @@ import { splitApiFactory } from '@splitsoftware/splitio-commons/src/services/spl
22import { ISplitApi } from '@splitsoftware/splitio-commons/src/services/types' ;
33import { IStorageAsync , ITelemetryCacheAsync } from '@splitsoftware/splitio-commons/src/storages/types' ;
44import { ISettings } from '@splitsoftware/splitio-commons/src/types' ;
5- import { SegmentsSynchronizer } from './synchronizers/SegmentsSynchronizer' ;
6- import { SplitsSynchronizer } from './synchronizers/SplitsSynchronizer' ;
5+ import { segmentChangesFetcherFactory } from '@splitsoftware/splitio-commons/src/sync/polling/fetchers/segmentChangesFetcher' ;
6+ import { segmentChangesUpdaterFactory } from '@splitsoftware/splitio-commons/src/sync/polling/updaters/segmentChangesUpdater' ;
7+ import { splitChangesFetcherFactory } from '@splitsoftware/splitio-commons/src/sync/polling/fetchers/splitChangesFetcher' ;
8+ import { splitChangesUpdaterFactory } from '@splitsoftware/splitio-commons/src/sync/polling/updaters/splitChangesUpdater' ;
79import { synchronizerStorageFactory } from './storages/synchronizerStorage' ;
810import { eventsSubmitterFactory } from './submitters/eventsSubmitter' ;
911import { impressionsSubmitterFactory } from './submitters/impressionsSubmitter' ;
@@ -36,13 +38,13 @@ export class Synchronizer {
3638 */
3739 private _splitApi : ISplitApi ;
3840 /**
39- * The local reference to the SegmentsUpdater instance from `@splitio/javascript-commons`.
41+ * The local reference to the segmentChangesUpdater instance from `@splitio/javascript-commons`.
4042 */
41- private _segmentsSynchronizer ! : SegmentsSynchronizer ;
43+ private _segmentChangesUpdater ! : ReturnType < typeof segmentChangesUpdaterFactory > ;
4244 /**
43- * The local reference to the SplitUpdater instance from `@splitio/javascript-commons`.
45+ * The local reference to the splitChangesUpdater instance from `@splitio/javascript-commons`.
4446 */
45- private _splitsSynchronizer ! : SplitsSynchronizer ;
47+ private _splitChangesUpdater ! : ReturnType < typeof splitChangesUpdaterFactory > ;
4648 /**
4749 * The local reference to the EventsSynchronizer class.
4850 */
@@ -137,15 +139,16 @@ export class Synchronizer {
137139 new ImpressionCountsCacheInMemory ( ) :
138140 undefined ;
139141
140- this . _segmentsSynchronizer = new SegmentsSynchronizer (
141- this . _splitApi . fetchSegmentChanges ,
142- this . settings ,
142+ this . _segmentChangesUpdater = segmentChangesUpdaterFactory (
143+ this . settings . log ,
144+ segmentChangesFetcherFactory ( this . _splitApi . fetchSegmentChanges ) ,
143145 this . _storage . segments ,
144146 ) ;
145- this . _splitsSynchronizer = new SplitsSynchronizer (
146- this . _splitApi . fetchSplitChanges ,
147- this . settings ,
147+ this . _splitChangesUpdater = splitChangesUpdaterFactory (
148+ this . settings . log ,
149+ splitChangesFetcherFactory ( this . _splitApi . fetchSplitChanges , this . settings , this . _storage ) ,
148150 this . _storage ,
151+ this . settings . sync . __splitFiltersValidation
149152 ) ;
150153 this . _eventsSubmitter = eventsSubmitterFactory (
151154 this . settings . log ,
@@ -260,11 +263,10 @@ export class Synchronizer {
260263 private async executeSplitsAndSegments ( standalone = true ) {
261264 if ( standalone ) await this . preExecute ( ) ;
262265
263- // @TODO optimize SplitChangesUpdater to reduce storage operations ("inMemoryOperation" mode)
264- const isSplitsSyncSuccessful = await this . _splitsSynchronizer . getSplitChanges ( ) ;
266+ const isSplitsSyncSuccessful = await this . _splitChangesUpdater ( ) ;
265267
266268 this . settings . log . debug ( `Feature flags Synchronizer task: ${ isSplitsSyncSuccessful ? 'Successful' : 'Unsuccessful' } ` ) ;
267- const isSegmentsSyncSuccessful = await this . _segmentsSynchronizer . getSegmentsChanges ( ) ;
269+ const isSegmentsSyncSuccessful = await this . _segmentChangesUpdater ( ) ;
268270 this . settings . log . debug ( `Segments Synchronizer task: ${ isSegmentsSyncSuccessful ? 'Successful' : 'Unsuccessful' } ` ) ;
269271
270272 if ( standalone ) await this . postExecute ( ) ;
0 commit comments