2323from splitio .storage .inmemmory import InMemorySplitStorage , InMemorySegmentStorage , \
2424 InMemoryImpressionStorage , InMemoryEventStorage , InMemoryTelemetryStorage , LocalhostTelemetryStorage , \
2525 InMemorySplitStorageAsync , InMemorySegmentStorageAsync , InMemoryImpressionStorageAsync , \
26- InMemoryEventStorageAsync , InMemoryTelemetryStorageAsync , LocalhostTelemetryStorageAsync
26+ InMemoryEventStorageAsync , InMemoryTelemetryStorageAsync , LocalhostTelemetryStorageAsync , \
27+ InMemoryRuleBasedSegmentStorage , InMemoryRuleBasedSegmentStorageAsync
2728from splitio .storage .adapters import redis
2829from splitio .storage .redis import RedisSplitStorage , RedisSegmentStorage , RedisImpressionsStorage , \
2930 RedisEventsStorage , RedisTelemetryStorage , RedisSplitStorageAsync , RedisEventsStorageAsync ,\
30- RedisSegmentStorageAsync , RedisImpressionsStorageAsync , RedisTelemetryStorageAsync
31+ RedisSegmentStorageAsync , RedisImpressionsStorageAsync , RedisTelemetryStorageAsync , \
32+ RedisRuleBasedSegmentsStorage , RedisRuleBasedSegmentsStorageAsync
3133from splitio .storage .pluggable import PluggableEventsStorage , PluggableImpressionsStorage , PluggableSegmentStorage , \
3234 PluggableSplitStorage , PluggableTelemetryStorage , PluggableTelemetryStorageAsync , PluggableEventsStorageAsync , \
33- PluggableImpressionsStorageAsync , PluggableSegmentStorageAsync , PluggableSplitStorageAsync
35+ PluggableImpressionsStorageAsync , PluggableSegmentStorageAsync , PluggableSplitStorageAsync , \
36+ PluggableRuleBasedSegmentsStorage , PluggableRuleBasedSegmentsStorageAsync
3437
3538# APIs
3639from splitio .api .client import HttpClient , HttpClientAsync , HttpClientKerberos
@@ -543,6 +546,7 @@ def _build_in_memory_factory(api_key, cfg, sdk_url=None, events_url=None, # pyl
543546 storages = {
544547 'splits' : InMemorySplitStorage (cfg ['flagSetsFilter' ] if cfg ['flagSetsFilter' ] is not None else []),
545548 'segments' : InMemorySegmentStorage (),
549+ 'rule_based_segments' : InMemoryRuleBasedSegmentStorage (),
546550 'impressions' : InMemoryImpressionStorage (cfg ['impressionsQueueSize' ], telemetry_runtime_producer ),
547551 'events' : InMemoryEventStorage (cfg ['eventsQueueSize' ], telemetry_runtime_producer ),
548552 }
@@ -559,7 +563,7 @@ def _build_in_memory_factory(api_key, cfg, sdk_url=None, events_url=None, # pyl
559563 imp_strategy , none_strategy , telemetry_runtime_producer )
560564
561565 synchronizers = SplitSynchronizers (
562- SplitSynchronizer (apis ['splits' ], storages ['splits' ]),
566+ SplitSynchronizer (apis ['splits' ], storages ['splits' ], storages [ 'rule_based_segments' ] ),
563567 SegmentSynchronizer (apis ['segments' ], storages ['splits' ], storages ['segments' ]),
564568 ImpressionSynchronizer (apis ['impressions' ], storages ['impressions' ],
565569 cfg ['impressionsBulkSize' ]),
@@ -671,6 +675,7 @@ async def _build_in_memory_factory_async(api_key, cfg, sdk_url=None, events_url=
671675 storages = {
672676 'splits' : InMemorySplitStorageAsync (cfg ['flagSetsFilter' ] if cfg ['flagSetsFilter' ] is not None else []),
673677 'segments' : InMemorySegmentStorageAsync (),
678+ 'rule_based_segments' : InMemoryRuleBasedSegmentStorageAsync (),
674679 'impressions' : InMemoryImpressionStorageAsync (cfg ['impressionsQueueSize' ], telemetry_runtime_producer ),
675680 'events' : InMemoryEventStorageAsync (cfg ['eventsQueueSize' ], telemetry_runtime_producer ),
676681 }
@@ -687,7 +692,7 @@ async def _build_in_memory_factory_async(api_key, cfg, sdk_url=None, events_url=
687692 imp_strategy , none_strategy , telemetry_runtime_producer )
688693
689694 synchronizers = SplitSynchronizers (
690- SplitSynchronizerAsync (apis ['splits' ], storages ['splits' ]),
695+ SplitSynchronizerAsync (apis ['splits' ], storages ['splits' ], storages [ 'rule_based_segments' ] ),
691696 SegmentSynchronizerAsync (apis ['segments' ], storages ['splits' ], storages ['segments' ]),
692697 ImpressionSynchronizerAsync (apis ['impressions' ], storages ['impressions' ],
693698 cfg ['impressionsBulkSize' ]),
@@ -756,6 +761,7 @@ def _build_redis_factory(api_key, cfg):
756761 storages = {
757762 'splits' : RedisSplitStorage (redis_adapter , cache_enabled , cache_ttl , []),
758763 'segments' : RedisSegmentStorage (redis_adapter ),
764+ 'rule_based_segments' : RedisRuleBasedSegmentsStorage (redis_adapter ),
759765 'impressions' : RedisImpressionsStorage (redis_adapter , sdk_metadata ),
760766 'events' : RedisEventsStorage (redis_adapter , sdk_metadata ),
761767 'telemetry' : RedisTelemetryStorage (redis_adapter , sdk_metadata )
@@ -839,6 +845,7 @@ async def _build_redis_factory_async(api_key, cfg):
839845 storages = {
840846 'splits' : RedisSplitStorageAsync (redis_adapter , cache_enabled , cache_ttl ),
841847 'segments' : RedisSegmentStorageAsync (redis_adapter ),
848+ 'rule_based_segments' : RedisRuleBasedSegmentsStorageAsync (redis_adapter ),
842849 'impressions' : RedisImpressionsStorageAsync (redis_adapter , sdk_metadata ),
843850 'events' : RedisEventsStorageAsync (redis_adapter , sdk_metadata ),
844851 'telemetry' : await RedisTelemetryStorageAsync .create (redis_adapter , sdk_metadata )
@@ -922,6 +929,7 @@ def _build_pluggable_factory(api_key, cfg):
922929 storages = {
923930 'splits' : PluggableSplitStorage (pluggable_adapter , storage_prefix , []),
924931 'segments' : PluggableSegmentStorage (pluggable_adapter , storage_prefix ),
932+ 'rule_based_segments' : PluggableRuleBasedSegmentsStorage (pluggable_adapter , storage_prefix ),
925933 'impressions' : PluggableImpressionsStorage (pluggable_adapter , sdk_metadata , storage_prefix ),
926934 'events' : PluggableEventsStorage (pluggable_adapter , sdk_metadata , storage_prefix ),
927935 'telemetry' : PluggableTelemetryStorage (pluggable_adapter , sdk_metadata , storage_prefix )
@@ -1003,6 +1011,7 @@ async def _build_pluggable_factory_async(api_key, cfg):
10031011 storages = {
10041012 'splits' : PluggableSplitStorageAsync (pluggable_adapter , storage_prefix ),
10051013 'segments' : PluggableSegmentStorageAsync (pluggable_adapter , storage_prefix ),
1014+ 'rule_based_segments' : PluggableRuleBasedSegmentsStorageAsync (pluggable_adapter , storage_prefix ),
10061015 'impressions' : PluggableImpressionsStorageAsync (pluggable_adapter , sdk_metadata , storage_prefix ),
10071016 'events' : PluggableEventsStorageAsync (pluggable_adapter , sdk_metadata , storage_prefix ),
10081017 'telemetry' : await PluggableTelemetryStorageAsync .create (pluggable_adapter , sdk_metadata , storage_prefix )
@@ -1081,13 +1090,15 @@ def _build_localhost_factory(cfg):
10811090 storages = {
10821091 'splits' : InMemorySplitStorage (cfg ['flagSetsFilter' ] if cfg ['flagSetsFilter' ] is not None else []),
10831092 'segments' : InMemorySegmentStorage (), # not used, just to avoid possible future errors.
1093+ 'rule_based_segments' : InMemoryRuleBasedSegmentStorage (),
10841094 'impressions' : LocalhostImpressionsStorage (),
10851095 'events' : LocalhostEventsStorage (),
10861096 }
10871097 localhost_mode = LocalhostMode .JSON if cfg ['splitFile' ][- 5 :].lower () == '.json' else LocalhostMode .LEGACY
10881098 synchronizers = SplitSynchronizers (
10891099 LocalSplitSynchronizer (cfg ['splitFile' ],
10901100 storages ['splits' ],
1101+ storages ['rule_based_segments' ],
10911102 localhost_mode ),
10921103 LocalSegmentSynchronizer (cfg ['segmentDirectory' ], storages ['splits' ], storages ['segments' ]),
10931104 None , None , None ,
@@ -1151,13 +1162,15 @@ async def _build_localhost_factory_async(cfg):
11511162 storages = {
11521163 'splits' : InMemorySplitStorageAsync (),
11531164 'segments' : InMemorySegmentStorageAsync (), # not used, just to avoid possible future errors.
1165+ 'rule_based_segments' : InMemoryRuleBasedSegmentStorageAsync (),
11541166 'impressions' : LocalhostImpressionsStorageAsync (),
11551167 'events' : LocalhostEventsStorageAsync (),
11561168 }
11571169 localhost_mode = LocalhostMode .JSON if cfg ['splitFile' ][- 5 :].lower () == '.json' else LocalhostMode .LEGACY
11581170 synchronizers = SplitSynchronizers (
11591171 LocalSplitSynchronizerAsync (cfg ['splitFile' ],
11601172 storages ['splits' ],
1173+ storages ['rule_based_segments' ],
11611174 localhost_mode ),
11621175 LocalSegmentSynchronizerAsync (cfg ['segmentDirectory' ], storages ['splits' ], storages ['segments' ]),
11631176 None , None , None ,
0 commit comments