77from splitio .util .time import utctime_ms
88from splitio .push .sse import SSE_EVENT_ERROR , SSE_EVENT_MESSAGE
99
10-
1110class EventType (Enum ):
1211 """Event type enumeration."""
1312
@@ -277,7 +276,7 @@ def __str__(self):
277276
278277
279278class BaseUpdate (BaseMessage , metaclass = abc .ABCMeta ):
280- """Split data update notification."""
279+ """Feature flag data update notification."""
281280
282281 def __init__ (self , channel , timestamp , change_number ):
283282 """
@@ -324,11 +323,14 @@ def change_number(self):
324323
325324
326325class SplitChangeUpdate (BaseUpdate ):
327- """Split Change notification."""
326+ """Feature flag Change notification."""
328327
329- def __init__ (self , channel , timestamp , change_number ):
328+ def __init__ (self , channel , timestamp , change_number , previous_change_number , feature_flag_definition , compression ):
330329 """Class constructor."""
331330 BaseUpdate .__init__ (self , channel , timestamp , change_number )
331+ self ._previous_change_number = previous_change_number
332+ self ._feature_flag_definition = feature_flag_definition
333+ self ._compression = compression
332334
333335 @property
334336 def update_type (self ): # pylint:disable=no-self-use
@@ -340,18 +342,48 @@ def update_type(self): # pylint:disable=no-self-use
340342 """
341343 return UpdateType .SPLIT_UPDATE
342344
345+ @property
346+ def previous_change_number (self ): # pylint:disable=no-self-use
347+ """
348+ Return previous change number
349+
350+ :returns: The previous change number
351+ :rtype: int
352+ """
353+ return self ._previous_change_number
354+
355+ @property
356+ def feature_flag_definition (self ): # pylint:disable=no-self-use
357+ """
358+ Return feature flag definition
359+
360+ :returns: The new feature flag definition
361+ :rtype: str
362+ """
363+ return self ._feature_flag_definition
364+
365+ @property
366+ def compression (self ): # pylint:disable=no-self-use
367+ """
368+ Return previous compression type
369+
370+ :returns: The compression type
371+ :rtype: int
372+ """
373+ return self ._compression
374+
343375 def __str__ (self ):
344376 """Return string representation."""
345377 return "SplitChange - changeNumber=%d" % (self .change_number )
346378
347379
348380class SplitKillUpdate (BaseUpdate ):
349- """Split Kill notification."""
381+ """Feature flag Kill notification."""
350382
351- def __init__ (self , channel , timestamp , change_number , split_name , default_treatment ): # pylint:disable=too-many-arguments
383+ def __init__ (self , channel , timestamp , change_number , feature_flag_name , default_treatment ): # pylint:disable=too-many-arguments
352384 """Class constructor."""
353385 BaseUpdate .__init__ (self , channel , timestamp , change_number )
354- self ._split_name = split_name
386+ self ._feature_flag_name = feature_flag_name
355387 self ._default_treatment = default_treatment
356388
357389 @property
@@ -365,14 +397,14 @@ def update_type(self): # pylint:disable=no-self-use
365397 return UpdateType .SPLIT_KILL
366398
367399 @property
368- def split_name (self ):
400+ def feature_flag_name (self ):
369401 """
370- Return the name of the killed split .
402+ Return the name of the killed feature flag .
371403
372- :returns: name of the killed split
404+ :returns: name of the killed feature flag
373405 :rtype: str
374406 """
375- return self ._split_name
407+ return self ._feature_flag_name
376408
377409 @property
378410 def default_treatment (self ):
@@ -387,7 +419,7 @@ def default_treatment(self):
387419 def __str__ (self ):
388420 """Return string representation."""
389421 return "SplitKill - changeNumber=%d, name=%s, defaultTreatment=%s" % \
390- (self .change_number , self .split_name , self .default_treatment )
422+ (self .change_number , self .feature_flag_name , self .default_treatment )
391423
392424
393425class SegmentChangeUpdate (BaseUpdate ):
@@ -471,9 +503,9 @@ def _parse_update(channel, timestamp, data):
471503 """
472504 update_type = UpdateType (data ['type' ])
473505 change_number = data ['changeNumber' ]
474- if update_type == UpdateType .SPLIT_UPDATE :
475- return SplitChangeUpdate (channel , timestamp , change_number )
476- elif update_type == UpdateType .SPLIT_KILL :
506+ if update_type == UpdateType .SPLIT_UPDATE and change_number is not None :
507+ return SplitChangeUpdate (channel , timestamp , change_number , data . get ( 'pcn' ), data . get ( 'd' ), data . get ( 'c' ) )
508+ elif update_type == UpdateType .SPLIT_KILL and change_number is not None :
477509 return SplitKillUpdate (channel , timestamp , change_number ,
478510 data ['splitName' ], data ['defaultTreatment' ])
479511 elif update_type == UpdateType .SEGMENT_UPDATE :
0 commit comments