Skip to content

Commit 25f4798

Browse files
authored
Merge pull request #350 from splitio/dw-update-sync.split
updated logs and comments in sync.split
2 parents 26faabc + 4ea6568 commit 25f4798

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

splitio/sync/split.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828

2929

3030
class SplitSynchronizer(object):
31-
"""Split changes synchronizer."""
31+
"""Feature Flag changes synchronizer."""
3232

3333
def __init__(self, split_api, split_storage):
3434
"""
3535
Class constructor.
3636
37-
:param split_api: Split API Client.
37+
:param split_api: Feature Flag API Client.
3838
:type split_api: splitio.api.splits.SplitsAPI
3939
40-
:param split_storage: Split Storage.
40+
:param split_storage: Feature Flag Storage.
4141
:type split_storage: splitio.storage.InMemorySplitStorage
4242
"""
4343
self._api = split_api
@@ -50,7 +50,7 @@ def _fetch_until(self, fetch_options, till=None):
5050
"""
5151
Hit endpoint, update storage and return when since==till.
5252
53-
:param fetch_options Fetch options for getting split definitions.
53+
:param fetch_options Fetch options for getting feature flag definitions.
5454
:type fetch_options splitio.api.FetchOptions
5555
5656
:param till: Passed till from Streaming.
@@ -71,7 +71,7 @@ def _fetch_until(self, fetch_options, till=None):
7171
try:
7272
split_changes = self._api.fetch_splits(change_number, fetch_options)
7373
except APIException as exc:
74-
_LOGGER.error('Exception raised while fetching splits')
74+
_LOGGER.error('Exception raised while fetching feature flags')
7575
_LOGGER.debug('Exception information: ', exc_info=True)
7676
raise exc
7777

@@ -90,7 +90,7 @@ def _attempt_split_sync(self, fetch_options, till=None):
9090
"""
9191
Hit endpoint, update storage and return True if sync is complete.
9292
93-
:param fetch_options Fetch options for getting split definitions.
93+
:param fetch_options Fetch options for getting feature flag definitions.
9494
:type fetch_options splitio.api.FetchOptions
9595
9696
:param till: Passed till from Streaming.
@@ -143,9 +143,9 @@ def synchronize_splits(self, till=None):
143143

144144
def kill_split(self, split_name, default_treatment, change_number):
145145
"""
146-
Local kill for split.
146+
Local kill for feature flag.
147147
148-
:param split_name: name of the split to perform kill
148+
:param split_name: name of the feature flag to perform kill
149149
:type split_name: str
150150
:param default_treatment: name of the default treatment to return
151151
:type default_treatment: str
@@ -169,9 +169,9 @@ def __init__(self, filename, split_storage, localhost_mode=LocalhostMode.LEGACY)
169169
"""
170170
Class constructor.
171171
172-
:param filename: File to parse splits from.
172+
:param filename: File to parse feature flags from.
173173
:type filename: str
174-
:param split_storage: Split Storage.
174+
:param split_storage: Feature flag Storage.
175175
:type split_storage: splitio.storage.InMemorySplitStorage
176176
:param localhost_mode: mode for localhost either JSON, YAML or LEGACY.
177177
:type localhost_mode: splitio.sync.split.LocalhostMode
@@ -184,9 +184,9 @@ def __init__(self, filename, split_storage, localhost_mode=LocalhostMode.LEGACY)
184184
@staticmethod
185185
def _make_split(split_name, conditions, configs=None):
186186
"""
187-
Make a split with a single all_keys matcher.
187+
Make a Feature flag with a single all_keys matcher.
188188
189-
:param split_name: Name of the split.
189+
:param split_name: Name of the feature flag.
190190
:type split_name: str.
191191
"""
192192
return splits.from_raw({
@@ -248,12 +248,12 @@ def _make_whitelist_condition(whitelist, treatment):
248248
@classmethod
249249
def _read_splits_from_legacy_file(cls, filename):
250250
"""
251-
Parse a splits file and return a populated storage.
251+
Parse a feature flags file and return a populated storage.
252252
253-
:param filename: Path of the file containing mocked splits & treatments.
253+
:param filename: Path of the file containing mocked feature flags & treatments.
254254
:type filename: str.
255255
256-
:return: Storage populataed with splits ready to be evaluated.
256+
:return: Storage populataed with feature flags ready to be evaluated.
257257
:rtype: InMemorySplitStorage
258258
"""
259259
to_return = {}
@@ -266,7 +266,7 @@ def _read_splits_from_legacy_file(cls, filename):
266266
definition_match = _LEGACY_DEFINITION_LINE_RE.match(line)
267267
if not definition_match:
268268
_LOGGER.warning(
269-
'Invalid line on localhost environment split '
269+
'Invalid line on localhost environment feature flag '
270270
'definition. Line = %s',
271271
line
272272
)
@@ -283,12 +283,12 @@ def _read_splits_from_legacy_file(cls, filename):
283283
@classmethod
284284
def _read_splits_from_yaml_file(cls, filename):
285285
"""
286-
Parse a splits file and return a populated storage.
286+
Parse a feature flags file and return a populated storage.
287287
288-
:param filename: Path of the file containing mocked splits & treatments.
288+
:param filename: Path of the file containing mocked feature flags & treatments.
289289
:type filename: str.
290290
291-
:return: Storage populataed with splits ready to be evaluated.
291+
:return: Storage populated with feature flags ready to be evaluated.
292292
:rtype: InMemorySplitStorage
293293
"""
294294
try:
@@ -320,17 +320,17 @@ def _read_splits_from_yaml_file(cls, filename):
320320
raise ValueError("Error parsing file %s. Make sure it's readable." % filename) from exc
321321

322322
def synchronize_splits(self, till=None): # pylint:disable=unused-argument
323-
"""Update splits in storage."""
324-
_LOGGER.info('Synchronizing splits now.')
323+
"""Update feature flags in storage."""
324+
_LOGGER.info('Synchronizing feature flags now.')
325325
try:
326326
return self._synchronize_json() if self._localhost_mode == LocalhostMode.JSON else self._synchronize_legacy()
327327
except Exception as exc:
328328
_LOGGER.error(str(exc))
329-
raise APIException("Error fetching splits information") from exc
329+
raise APIException("Error fetching feature flags information") from exc
330330

331331
def _synchronize_legacy(self):
332332
"""
333-
Update splits in storage for legacy mode.
333+
Update feature flags in storage for legacy mode.
334334
335335
:return: empty array for compatibility with json mode
336336
:rtype: []
@@ -352,7 +352,7 @@ def _synchronize_legacy(self):
352352

353353
def _synchronize_json(self):
354354
"""
355-
Update splits in storage for json mode.
355+
Update feature flags in storage for json mode.
356356
357357
:return: segment names string array
358358
:rtype: [str]
@@ -370,24 +370,24 @@ def _synchronize_json(self):
370370
if split['status'] == splits.Status.ACTIVE.value:
371371
parsed = splits.from_raw(split)
372372
self._split_storage.put(parsed)
373-
_LOGGER.debug("split %s is updated", parsed.name)
373+
_LOGGER.debug("feature flag %s is updated", parsed.name)
374374
segment_list.update(set(parsed.get_segment_names()))
375375
else:
376376
self._split_storage.remove(split['name'])
377377

378378
self._split_storage.set_change_number(till)
379379
return segment_list
380380
except Exception as exc:
381-
raise ValueError("Error reading splits from json.") from exc
381+
raise ValueError("Error reading feature flags from json.") from exc
382382

383383
def _read_splits_from_json_file(self, filename):
384384
"""
385-
Parse a splits file and return a populated storage.
385+
Parse a feature flags file and return a populated storage.
386386
387-
:param filename: Path of the file containing split
387+
:param filename: Path of the file containing feature flags
388388
:type filename: str.
389389
390-
:return: Tuple: sanitized split structure dict and till
390+
:return: Tuple: sanitized feature flag structure dict and till
391391
:rtype: Tuple(Dict, int)
392392
"""
393393
try:
@@ -403,7 +403,7 @@ def _sanitize_split(self, parsed):
403403
"""
404404
implement Sanitization if neded.
405405
406-
:param parsed: splits, till and since elements dict
406+
:param parsed: feature flags, till and since elements dict
407407
:type parsed: Dict
408408
409409
:return: sanitized structure dict
@@ -418,7 +418,7 @@ def _sanitize_json_elements(self, parsed):
418418
"""
419419
Sanitize all json elements.
420420
421-
:param parsed: splits, till and since elements dict
421+
:param parsed: feature flags, till and since elements dict
422422
:type parsed: Dict
423423
424424
:return: sanitized structure dict
@@ -435,9 +435,9 @@ def _sanitize_json_elements(self, parsed):
435435

436436
def _sanitize_split_elements(self, parsed_splits):
437437
"""
438-
Sanitize all splits elements.
438+
Sanitize all feature flags elements.
439439
440-
:param parsed_splits: splits array
440+
:param parsed_splits: feature flags array
441441
:type parsed_splits: [Dict]
442442
443443
:return: sanitized structure dict
@@ -446,7 +446,7 @@ def _sanitize_split_elements(self, parsed_splits):
446446
sanitized_splits = []
447447
for split in parsed_splits:
448448
if 'name' not in split or split['name'].strip() == '':
449-
_LOGGER.warning("A split in json file does not have (Name) or property is empty, skipping.")
449+
_LOGGER.warning("A feature flag in json file does not have (Name) or property is empty, skipping.")
450450
continue
451451
for element in [('trafficTypeName', 'user', None, None, None, None),
452452
('trafficAllocation', 100, 0, 100, None, None),
@@ -464,12 +464,12 @@ def _sanitize_split_elements(self, parsed_splits):
464464

465465
def _sanitize_condition(self, split):
466466
"""
467-
Sanitize split and ensure a condition type ROLLOUT and matcher exist with ALL_KEYS elements.
467+
Sanitize feature flag and ensure a condition type ROLLOUT and matcher exist with ALL_KEYS elements.
468468
469-
:param split: split dict object
469+
:param split: feature flag dict object
470470
:type split: Dict
471471
472-
:return: sanitized split
472+
:return: sanitized feature flag
473473
:rtype: Dict
474474
"""
475475
found_all_keys_matcher = False
@@ -486,7 +486,7 @@ def _sanitize_condition(self, split):
486486
break
487487

488488
if not found_all_keys_matcher:
489-
_LOGGER.debug("Missing default rule condition for split: %s, adding default rule with 100%% off treatment", split['name'])
489+
_LOGGER.debug("Missing default rule condition for feature flag: %s, adding default rule with 100%% off treatment", split['name'])
490490
split['conditions'].append(
491491
{
492492
"conditionType": "ROLLOUT",

0 commit comments

Comments
 (0)