@@ -23,6 +23,12 @@ class CompressionMode(Enum):
2323 GZIP_COMPRESSION = 1
2424 ZLIB_COMPRESSION = 2
2525
26+ _compression_handlers = {
27+ CompressionMode .NO_COMPRESSION : lambda event : base64 .b64decode (event .feature_flag_definition ),
28+ CompressionMode .GZIP_COMPRESSION : lambda event : gzip .decompress (base64 .b64decode (event .feature_flag_definition )).decode ('utf-8' ),
29+ CompressionMode .ZLIB_COMPRESSION : lambda event : zlib .decompress (base64 .b64decode (event .feature_flag_definition )).decode ('utf-8' ),
30+ }
31+
2632class WorkerBase (object , metaclass = abc .ABCMeta ):
2733 """Worker template."""
2834
@@ -41,7 +47,7 @@ def stop(self):
4147 def _get_feature_flag_definition (self , event ):
4248 """return feature flag definition in event."""
4349 cm = CompressionMode (event .compression ) # will throw if the number is not defined in compression mode
44- return self . _compression_handlers [cm ](event )
50+ return _compression_handlers [cm ](event )
4551
4652class SegmentWorker (WorkerBase ):
4753 """Segment Worker for processing updates."""
@@ -190,11 +196,6 @@ def __init__(self, synchronize_feature_flag, synchronize_segment, feature_flag_q
190196 self ._worker = None
191197 self ._feature_flag_storage = feature_flag_storage
192198 self ._segment_storage = segment_storage
193- self ._compression_handlers = {
194- CompressionMode .NO_COMPRESSION : lambda event : base64 .b64decode (event .feature_flag_definition ),
195- CompressionMode .GZIP_COMPRESSION : lambda event : gzip .decompress (base64 .b64decode (event .feature_flag_definition )).decode ('utf-8' ),
196- CompressionMode .ZLIB_COMPRESSION : lambda event : zlib .decompress (base64 .b64decode (event .feature_flag_definition )).decode ('utf-8' ),
197- }
198199 self ._telemetry_runtime_producer = telemetry_runtime_producer
199200
200201 def is_running (self ):
@@ -233,13 +234,11 @@ def _run(self):
233234 continue
234235 except Exception as e :
235236 _LOGGER .error ('Exception raised in updating feature flag' )
236- _LOGGER .debug (str (e ))
237237 _LOGGER .debug ('Exception information: ' , exc_info = True )
238238 pass
239239 self ._handler (event .change_number )
240240 except Exception as e : # pylint: disable=broad-except
241241 _LOGGER .error ('Exception raised in feature flag synchronization' )
242- _LOGGER .debug (str (e ))
243242 _LOGGER .debug ('Exception information: ' , exc_info = True )
244243
245244 def start (self ):
@@ -290,11 +289,6 @@ def __init__(self, synchronize_feature_flag, synchronize_segment, feature_flag_q
290289 self ._running = False
291290 self ._feature_flag_storage = feature_flag_storage
292291 self ._segment_storage = segment_storage
293- self ._compression_handlers = {
294- CompressionMode .NO_COMPRESSION : lambda event : base64 .b64decode (event .feature_flag_definition ),
295- CompressionMode .GZIP_COMPRESSION : lambda event : gzip .decompress (base64 .b64decode (event .feature_flag_definition )).decode ('utf-8' ),
296- CompressionMode .ZLIB_COMPRESSION : lambda event : zlib .decompress (base64 .b64decode (event .feature_flag_definition )).decode ('utf-8' ),
297- }
298292 self ._telemetry_runtime_producer = telemetry_runtime_producer
299293
300294 def is_running (self ):
@@ -333,13 +327,11 @@ async def _run(self):
333327 continue
334328 except Exception as e :
335329 _LOGGER .error ('Exception raised in updating feature flag' )
336- _LOGGER .debug (str (e ))
337330 _LOGGER .debug ('Exception information: ' , exc_info = True )
338331 pass
339332 await self ._handler (event .change_number )
340333 except Exception as e : # pylint: disable=broad-except
341334 _LOGGER .error ('Exception raised in split synchronization' )
342- _LOGGER .debug (str (e ))
343335 _LOGGER .debug ('Exception information: ' , exc_info = True )
344336
345337 def start (self ):
0 commit comments