Skip to content

Commit 9bf392f

Browse files
authored
Merge pull request #229 from splitio/usgi/deprecation
Usgi/deprecation
2 parents b82facd + 7850aa6 commit 9bf392f

25 files changed

+61
-1654
lines changed

CHANGES.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
9.0.0 (Apr 21, 2021)
2-
- BREAKING CHANGE: Deprecated Python2.
1+
9.0.0 (Apr 30, 2021)
2+
- BREAKING CHANGE: Removed splitSdkMachineIp and splitSdkMachineName configs.
3+
- BREAKING CHANGE: Deprecated uWSGI local cache.
4+
- BREAKING CHANGE: Deprecated Python2 support.
35
- Removed six, future and futures libs for compatibility between Python2 and Python3.
46
- Updated strings encoding to utf-8 by default for Redis.
57

splitio/client/config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
DEFAULT_CONFIG = {
1212
'operationMode': 'in-memory',
1313
'connectionTimeout': 1500,
14-
'splitSdkMachineName': None,
15-
'splitSdkMachineIp': None,
1614
'streamingEnabled': True,
1715
'featuresRefreshRate': 30,
1816
'segmentsRefreshRate': 30,
@@ -74,9 +72,6 @@ def _parse_operation_mode(apikey, config):
7472
if 'redisHost' in config or 'redisSentinels' in config:
7573
return 'redis-consumer'
7674

77-
if 'uwsgiClient' in config:
78-
return 'uwsgi-consumer'
79-
8075
return 'inmemory-standalone'
8176

8277

splitio/client/factory.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
from splitio.storage.adapters import redis
2020
from splitio.storage.redis import RedisSplitStorage, RedisSegmentStorage, RedisImpressionsStorage, \
2121
RedisEventsStorage, RedisTelemetryStorage
22-
from splitio.storage.adapters.uwsgi_cache import get_uwsgi
23-
from splitio.storage.uwsgi import UWSGIEventStorage, UWSGIImpressionStorage, UWSGISegmentStorage, \
24-
UWSGISplitStorage, UWSGITelemetryStorage
2522

2623
# APIs
2724
from splitio.api.client import HttpClient
@@ -420,36 +417,6 @@ def _build_redis_factory(api_key, cfg):
420417
)
421418

422419

423-
def _build_uwsgi_factory(api_key, cfg):
424-
"""Build and return a split factory with redis-based storage."""
425-
sdk_metadata = util.get_metadata(cfg)
426-
uwsgi_adapter = get_uwsgi()
427-
storages = {
428-
'splits': UWSGISplitStorage(uwsgi_adapter),
429-
'segments': UWSGISegmentStorage(uwsgi_adapter),
430-
'impressions': UWSGIImpressionStorage(uwsgi_adapter),
431-
'events': UWSGIEventStorage(uwsgi_adapter),
432-
'telemetry': UWSGITelemetryStorage(uwsgi_adapter)
433-
}
434-
recorder = StandardRecorder(
435-
ImpressionsManager(cfg['impressionsMode'], True,
436-
_wrap_impression_listener(cfg['impressionListener'], sdk_metadata)),
437-
storages['telemetry'],
438-
storages['events'],
439-
storages['impressions'],
440-
)
441-
_LOGGER.warning(
442-
"Beware: uwsgi-cache based operation mode is soon to be deprecated. Please consider " +
443-
"redis if you need a centralized point of syncrhonization, or in-memory (with preforking " +
444-
"support enabled) if running uwsgi with a master and several http workers)")
445-
return SplitFactory(
446-
api_key,
447-
storages,
448-
cfg['labelsEnabled'],
449-
recorder,
450-
)
451-
452-
453420
def _build_localhost_factory(cfg):
454421
"""Build and return a localhost factory for testing/development purposes."""
455422
storages = {
@@ -521,9 +488,6 @@ def get_factory(api_key, **kwargs):
521488
if config['operationMode'] == 'redis-consumer':
522489
return _build_redis_factory(api_key, config)
523490

524-
if config['operationMode'] == 'uwsgi-consumer':
525-
return _build_uwsgi_factory(api_key, config)
526-
527491
return _build_in_memory_factory(
528492
api_key,
529493
config,

splitio/client/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""General purpose SDK utilities."""
22

3-
import inspect
43
import socket
54
from collections import namedtuple
65
from splitio.version import __version__

splitio/engine/cache/lru.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
DEFAULT_MAX_SIZE = 5000
66

77

8-
class SimpleLruCache(object): #pylint: disable=too-many-instance-attributes
8+
class SimpleLruCache(object): # pylint: disable=too-many-instance-attributes
99
"""
1010
Key/Value local memory cache. with expiration & LRU eviction.
1111
@@ -21,7 +21,7 @@ class SimpleLruCache(object): #pylint: disable=too-many-instance-attributes
2121
None <---next--- || node || <---next--- || node || ... <---next--- || node ||
2222
"""
2323

24-
class _Node(object): #pylint: disable=too-few-public-methods
24+
class _Node(object): # pylint: disable=too-few-public-methods
2525
"""Links to previous an next items in the circular list."""
2626

2727
def __init__(self, key, value, previous_element, next_element):

splitio/engine/impressions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Split evaluator module."""
2-
import logging
32
import threading
43
from collections import defaultdict, namedtuple
54
from enum import Enum

splitio/models/datatypes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Datatypes converters for matchers."""
22

3+
34
def ts_truncate_seconds(timestamp):
45
"""
56
Set seconds to zero in a timestamp.
@@ -12,6 +13,7 @@ def ts_truncate_seconds(timestamp):
1213
"""
1314
return timestamp - (timestamp % 60)
1415

16+
1517
def ts_truncate_time(timestamp):
1618
"""
1719
Set time to zero in a timestamp.
@@ -24,6 +26,7 @@ def ts_truncate_time(timestamp):
2426
"""
2527
return timestamp - (timestamp % 86400)
2628

29+
2730
def java_ts_to_secs(java_ts):
2831
"""
2932
Convert java timestamp into unix timestamp.
@@ -36,6 +39,7 @@ def java_ts_to_secs(java_ts):
3639
"""
3740
return java_ts / 1000
3841

42+
3943
def java_ts_truncate_seconds(java_ts):
4044
"""
4145
Set seconds to zero in a timestamp.
@@ -48,6 +52,7 @@ def java_ts_truncate_seconds(java_ts):
4852
"""
4953
return ts_truncate_seconds(java_ts_to_secs(java_ts))
5054

55+
5156
def java_ts_truncate_time(java_ts):
5257
"""
5358
Set time to zero in a timestamp.

splitio/models/notification.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, channel, notification_type, control_type):
4040
self._channel = channel
4141
self._notification_type = Type(notification_type)
4242
self._control_type = Control(control_type)
43-
43+
4444
@property
4545
def channel(self):
4646
return self._channel
@@ -87,7 +87,7 @@ def change_number(self):
8787
@property
8888
def notification_type(self):
8989
return self._notification_type
90-
90+
9191
@property
9292
def segment_name(self):
9393
return self._segment_name
@@ -111,7 +111,7 @@ def __init__(self, channel, notification_type, change_number):
111111
self._channel = channel
112112
self._notification_type = Type(notification_type)
113113
self._change_number = change_number
114-
114+
115115
@property
116116
def channel(self):
117117
return self._channel
@@ -149,23 +149,23 @@ def __init__(self, channel, notification_type, change_number, default_treatment,
149149
self._change_number = change_number
150150
self._default_treatment = default_treatment
151151
self._split_name = split_name
152-
152+
153153
@property
154154
def channel(self):
155155
return self._channel
156-
156+
157157
@property
158158
def change_number(self):
159159
return self._change_number
160-
160+
161161
@property
162162
def default_treatment(self):
163163
return self._default_treatment
164-
164+
165165
@property
166166
def notification_type(self):
167167
return self._notification_type
168-
168+
169169
@property
170170
def split_name(self):
171171
return self._split_name
@@ -178,25 +178,26 @@ def split_name(self):
178178
Type.CONTROL: lambda c, d: ControlNotification(c, Type.CONTROL, d['controlType'])
179179
}
180180

181-
def wrap_notification(raw_data, channel):
182-
"""
183-
Parse notification from raw notification payload
184181

185-
:param raw_data: data
186-
:type raw_data: str
187-
:param channel: Channel of incoming notification
188-
:type channel: str
189-
"""
190-
try:
191-
if channel is None:
192-
raise ValueError("channel cannot be None.")
193-
raw_data = json.loads(raw_data)
194-
notification_type = Type(raw_data['type'])
195-
mapper = _NOTIFICATION_MAPPERS[notification_type]
196-
return mapper(channel, raw_data)
197-
except ValueError:
198-
raise ValueError("Wrong notification type received.")
199-
except KeyError:
200-
raise KeyError("Could not parse notification.")
201-
except TypeError:
202-
raise TypeError("Wrong JSON format.")
182+
def wrap_notification(raw_data, channel):
183+
"""
184+
Parse notification from raw notification payload
185+
186+
:param raw_data: data
187+
:type raw_data: str
188+
:param channel: Channel of incoming notification
189+
:type channel: str
190+
"""
191+
try:
192+
if channel is None:
193+
raise ValueError("channel cannot be None.")
194+
raw_data = json.loads(raw_data)
195+
notification_type = Type(raw_data['type'])
196+
mapper = _NOTIFICATION_MAPPERS[notification_type]
197+
return mapper(channel, raw_data)
198+
except ValueError:
199+
raise ValueError("Wrong notification type received.")
200+
except KeyError:
201+
raise KeyError("Could not parse notification.")
202+
except TypeError:
203+
raise TypeError("Wrong JSON format.")

splitio/models/token.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import base64
44
import json
55

6+
67
class Token(object):
78
"""Token object class."""
89

@@ -30,27 +31,27 @@ def __init__(self, push_enabled, token, channels, exp, iat):
3031
self._channels = channels
3132
self._exp = exp
3233
self._iat = iat
33-
34+
3435
@property
3536
def push_enabled(self):
3637
"""Return push_enabled"""
3738
return self._push_enabled
38-
39+
3940
@property
4041
def token(self):
4142
"""Return token"""
4243
return self._token
43-
44+
4445
@property
4546
def channels(self):
4647
"""Return channels"""
4748
return self._channels
48-
49+
4950
@property
5051
def exp(self):
5152
"""Return exp"""
5253
return self._exp
53-
54+
5455
@property
5556
def iat(self):
5657
"""Return iat"""
@@ -66,15 +67,16 @@ def decode_token(raw_token):
6667
push_enabled = raw_token['pushEnabled']
6768
if not push_enabled or len(token.strip()) == 0:
6869
return None, None, None
69-
70+
7071
token_parts = token.split('.')
7172
if len(token_parts) < 2:
7273
return None, None, None
73-
74+
7475
to_decode = token_parts[1]
75-
decoded_payload = base64.b64decode(to_decode + '='*(-len(to_decode) % 4))
76+
decoded_payload = base64.b64decode(to_decode + '='*(-len(to_decode) % 4))
7677
return push_enabled, token, json.loads(decoded_payload)
7778

79+
7880
def from_raw(raw_token):
7981
"""
8082
Parse a new token from a raw token response.

splitio/push/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _event_handler(self, event):
114114

115115
try:
116116
handle(parsed)
117-
except Exception: #pylint:disable=broad-except
117+
except Exception: # pylint:disable=broad-except
118118
_LOGGER.error('something went wrong when processing message of type %s',
119119
parsed.event_type)
120120
_LOGGER.debug(str(parsed), exc_info=True)

0 commit comments

Comments
 (0)