Skip to content

Commit 4673e55

Browse files
author
Matias Melograno
committed
merged with fixing sentinel config
2 parents 8aa6cc2 + 5bffc26 commit 4673e55

18 files changed

+673
-326
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
6.3.0 ()
2+
- Stored Impressions in Queue.
3+
- Fixed bug related to Machine Name and Machine IP.
14
6.2.2 (Dec 17, 2018)
25
- Fixed issue on selecting db for Sentinel.
36
6.2.1 (Dec 6, 2018)

splitio/brokers.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
AllKeysSplit, CacheBasedSplitFetcher
2727
from splitio.segments import ApiSegmentChangeFetcher, \
2828
SelfRefreshingSegmentFetcher, JSONFileSegmentFetcher
29-
from splitio.config import DEFAULT_CONFIG, MAX_INTERVAL, parse_config_file
29+
from splitio.config import DEFAULT_CONFIG, MAX_INTERVAL, parse_config_file, \
30+
set_machine_ip, set_machine_name
3031
from splitio.uwsgi import UWSGISplitCache, UWSGIImpressionsCache, \
3132
UWSGIMetricsCache, UWSGIEventsCache, get_uwsgi
3233
from splitio.tasks import EventsSyncTask
@@ -79,13 +80,13 @@ def get_change_number(self):
7980
"""
8081
return self.get_split_fetcher().change_number
8182

82-
def log_impression(self, impression):
83+
def log_impressions(self, impressions):
8384
"""
84-
Logs an impression after a get_treatment call
85+
Logs impressions after a get_treatments call
8586
:return: The treatment log implementation.
8687
:rtype: TreatmentLog
8788
"""
88-
return self.get_impression_log().log(impression)
89+
return self.get_impression_log().log_impressions(impressions)
8990

9091
def log_operation_time(self, operation, elapsed):
9192
"""Get the metrics implementation.
@@ -120,6 +121,7 @@ def get_events_log(self):
120121
def destroy(self):
121122
pass
122123

124+
123125
class JSONFileBroker(BaseBroker):
124126
def __init__(self, config, segment_changes_file_name, split_changes_file_name):
125127
"""
@@ -138,8 +140,8 @@ def __init__(self, config, segment_changes_file_name, split_changes_file_name):
138140
self._segment_changes_file_name = segment_changes_file_name
139141
self._split_changes_file_name = split_changes_file_name
140142
self._split_fetcher = self._build_split_fetcher()
141-
self._treatment_log = TreatmentLog() # Does nothing on ._log()
142-
self._metrics = Metrics() # Does nothing on .count(), .time(), .gauge()
143+
self._treatment_log = TreatmentLog() # Does nothing on ._log()
144+
self._metrics = Metrics() # Does nothing on .count(), .time(), .gauge()
143145

144146
def _build_split_fetcher(self):
145147
"""
@@ -183,6 +185,7 @@ def destroy(self):
183185
def get_events_log(self):
184186
return None
185187

188+
186189
class SelfRefreshingBroker(BaseBroker):
187190
def __init__(self, api_key, config=None, sdk_api_base_url=None,
188191
events_api_base_url=None, impression_listener=None):
@@ -488,7 +491,7 @@ def get_events_log(self):
488491
def refresh_splits(self):
489492
while not self._destroyed:
490493
time.sleep(self._split_refresh_period)
491-
if not self._destroyed: # DO NOT REMOVE
494+
if not self._destroyed: # DO NOT REMOVE
492495
# This check is used in case the client was
493496
# destroyed while the thread was sleeping
494497
# and the file was closed, in order to
@@ -590,7 +593,6 @@ def __init__(self, uwsgi, config=None):
590593
self._treatment_log = treatment_log
591594
self._metrics = metrics
592595

593-
594596
def get_split_fetcher(self):
595597
"""
596598
Get the split fetcher implementation for the broker.
@@ -640,6 +642,9 @@ def _init_config(api_key, **kwargs):
640642
file_config.update(config)
641643
config = file_config
642644

645+
set_machine_ip(config.get('splitSdkMachineIp'))
646+
set_machine_name(config.get('splitSdkMachineName'))
647+
643648
return api_key, config, sdk_api_base_url, events_api_base_url
644649

645650

splitio/cache.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ def add_impression(self, impression):
177177
"""
178178
pass # Do nothing
179179

180+
def add_impressions(self, impressions):
181+
"""
182+
Adds impression to the queue if it is enabled, otherwise the impression
183+
is dropped.
184+
:param impressions: The impression bulk
185+
:type impressions: list
186+
"""
187+
for impression in impressions:
188+
self.add_impression(impression)
189+
180190
def fetch_all(self):
181191
""" List all impressions.
182192
:return: A list of Impression tuples

0 commit comments

Comments
 (0)