@@ -2,8 +2,10 @@ import { splitApiFactory } from '@splitsoftware/splitio-commons/src/services/spl
2
2
import { ISplitApi } from '@splitsoftware/splitio-commons/src/services/types' ;
3
3
import { IStorageAsync , ITelemetryCacheAsync } from '@splitsoftware/splitio-commons/src/storages/types' ;
4
4
import { 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' ;
7
9
import { synchronizerStorageFactory } from './storages/synchronizerStorage' ;
8
10
import { eventsSubmitterFactory } from './submitters/eventsSubmitter' ;
9
11
import { impressionsSubmitterFactory } from './submitters/impressionsSubmitter' ;
@@ -36,13 +38,13 @@ export class Synchronizer {
36
38
*/
37
39
private _splitApi : ISplitApi ;
38
40
/**
39
- * The local reference to the SegmentsUpdater instance from `@splitio/javascript-commons`.
41
+ * The local reference to the segmentChangesUpdater instance from `@splitio/javascript-commons`.
40
42
*/
41
- private _segmentsSynchronizer ! : SegmentsSynchronizer ;
43
+ private _segmentChangesUpdater ! : ReturnType < typeof segmentChangesUpdaterFactory > ;
42
44
/**
43
- * The local reference to the SplitUpdater instance from `@splitio/javascript-commons`.
45
+ * The local reference to the splitChangesUpdater instance from `@splitio/javascript-commons`.
44
46
*/
45
- private _splitsSynchronizer ! : SplitsSynchronizer ;
47
+ private _splitChangesUpdater ! : ReturnType < typeof splitChangesUpdaterFactory > ;
46
48
/**
47
49
* The local reference to the EventsSynchronizer class.
48
50
*/
@@ -137,15 +139,16 @@ export class Synchronizer {
137
139
new ImpressionCountsCacheInMemory ( ) :
138
140
undefined ;
139
141
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 ) ,
143
145
this . _storage . segments ,
144
146
) ;
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 ) ,
148
150
this . _storage ,
151
+ this . settings . sync . __splitFiltersValidation
149
152
) ;
150
153
this . _eventsSubmitter = eventsSubmitterFactory (
151
154
this . settings . log ,
@@ -260,11 +263,10 @@ export class Synchronizer {
260
263
private async executeSplitsAndSegments ( standalone = true ) {
261
264
if ( standalone ) await this . preExecute ( ) ;
262
265
263
- // @TODO optimize SplitChangesUpdater to reduce storage operations ("inMemoryOperation" mode)
264
- const isSplitsSyncSuccessful = await this . _splitsSynchronizer . getSplitChanges ( ) ;
266
+ const isSplitsSyncSuccessful = await this . _splitChangesUpdater ( ) ;
265
267
266
268
this . settings . log . debug ( `Feature flags Synchronizer task: ${ isSplitsSyncSuccessful ? 'Successful' : 'Unsuccessful' } ` ) ;
267
- const isSegmentsSyncSuccessful = await this . _segmentsSynchronizer . getSegmentsChanges ( ) ;
269
+ const isSegmentsSyncSuccessful = await this . _segmentChangesUpdater ( ) ;
268
270
this . settings . log . debug ( `Segments Synchronizer task: ${ isSegmentsSyncSuccessful ? 'Successful' : 'Unsuccessful' } ` ) ;
269
271
270
272
if ( standalone ) await this . postExecute ( ) ;
0 commit comments