Skip to content

Commit c6a5bc6

Browse files
committed
minor fixes and polishing
1 parent 27353da commit c6a5bc6

5 files changed

Lines changed: 21 additions & 14 deletions

File tree

splitio/client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def track(self, key, traffic_type, event_type, value=None, properties=None):
370370
_LOGGER.error("Client is not ready - no calls possible")
371371
return False
372372
if not self.ready:
373-
_LOGGER.warn("track: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method")
373+
_LOGGER.warning("track: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method")
374374
self._telemetry_init_producer.record_not_ready_usage()
375375

376376
start = get_current_epoch_time_ms()

splitio/client/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def sanitize(apikey, config):
126126
processed['impressionsMode'] = imp_mode
127127
processed['impressionsRefreshRate'] = imp_rate
128128
if processed['metricsRefreshRate'] < 60:
129-
processed['metricsRefreshRate'] = 60
129+
_LOGGER.warning('metricRefreshRate parameter minimum value is 60 seconds, defaulting to 3600 seconds.')
130+
processed['metricsRefreshRate'] = 3600
130131

131132
return processed

splitio/client/factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,18 +525,18 @@ def _build_localhost_factory(cfg):
525525
'impressions': LocalhostImpressionsStorage(),
526526
'events': LocalhostEventsStorage(),
527527
}
528-
528+
localhost_mode = LocalhostMode.JSON if cfg['splitFile'][-5:].lower() == '.json' else LocalhostMode.LEGACY
529529
synchronizers = SplitSynchronizers(
530530
LocalSplitSynchronizer(cfg['splitFile'],
531531
storages['splits'],
532-
LocalhostMode.JSON if cfg['splitFile'][-5:].lower() == '.json' else LocalhostMode.LEGACY),
532+
localhost_mode),
533533
LocalSegmentSynchronizer(cfg['segmentDirectory'], storages['splits'], storages['segments']),
534534
None, None, None,
535535
)
536536

537537
split_sync_task = None
538538
segment_sync_task = None
539-
if cfg['localhostRefreshEnabled']:
539+
if cfg['localhostRefreshEnabled'] and localhost_mode == LocalhostMode.JSON:
540540
split_sync_task = SplitSynchronizationTask(
541541
synchronizers.split_sync.synchronize_splits,
542542
cfg['featuresRefreshRate'],

splitio/sync/split.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
_ON_DEMAND_FETCH_BACKOFF_BASE = 10 # backoff base starting at 10 seconds
26-
_ON_DEMAND_FETCH_BACKOFF_MAX_WAIT = 30 # don't sleep for more than 1 minute
26+
_ON_DEMAND_FETCH_BACKOFF_MAX_WAIT = 30 # don't sleep for more than 30 seconds
2727
_ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES = 10
2828

2929

@@ -481,15 +481,19 @@ def _santizie_condition(self, split):
481481
found_all_keys_matcher = False
482482
if 'conditions' not in split or split['conditions'] is None:
483483
split['conditions'] = []
484+
conditions_count = len(split['conditions'])
485+
count = 0
484486
for condition in split['conditions']:
485-
if 'conditionType' in condition:
486-
if condition['conditionType'] == 'ROLLOUT':
487-
if 'matcherGroup' in condition:
488-
if 'matchers' in condition['matcherGroup']:
489-
for matcher in condition['matcherGroup']['matchers']:
490-
if matcher['matcherType'] == 'ALL_KEYS':
491-
found_all_keys_matcher = True
492-
break
487+
count += 1
488+
if count == conditions_count: # checking only last condition
489+
if 'conditionType' in condition:
490+
if condition['conditionType'] == 'ROLLOUT':
491+
if 'matcherGroup' in condition:
492+
if 'matchers' in condition['matcherGroup']:
493+
for matcher in condition['matcherGroup']['matchers']:
494+
if matcher['matcherType'] == 'ALL_KEYS':
495+
found_all_keys_matcher = True
496+
break
493497

494498
if not found_all_keys_matcher:
495499
_LOGGER.debug("Missing default rule condition for split: %s, adding default rule with 100%% off treatment", split['name'])

tests/integration/test_client_e2e.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ def test_localhost_json_e2e(self):
10181018
assert client.get_treatment("key", "SPLIT_2", None) == 'on'
10191019

10201020
# Tests 2
1021+
factory._storages['splits'].remove('SPLIT_1')
10211022
factory._storages['splits'].remove('SPLIT_2')
10221023
factory._sync_manager._synchronizer._split_synchronizers._split_sync._split_storage.set_change_number(-1)
10231024
self._update_temp_file(splits_json['splitChange2_1'])
@@ -1066,6 +1067,7 @@ def test_localhost_json_e2e(self):
10661067
assert client.get_treatment("key", "SPLIT_2", None) == 'on'
10671068

10681069
# Tests 5
1070+
factory._storages['splits'].remove('SPLIT_1')
10691071
factory._storages['splits'].remove('SPLIT_2')
10701072
factory._sync_manager._synchronizer._split_synchronizers._split_sync._split_storage.set_change_number(-1)
10711073
self._update_temp_file(splits_json['splitChange5_1'])

0 commit comments

Comments
 (0)