gofeatureflag-python-provider 0.1.2__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gofeatureflag-python-provider
3
- Version: 0.1.2
3
+ Version: 0.2.0
4
4
  Summary: GO Feature Flag provider for OpenFeature
5
5
  Home-page: https://gofeatureflag.org
6
6
  License: Apache-2.0
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Requires-Dist: asyncio (>=3.4.3,<4.0.0)
19
- Requires-Dist: openfeature-sdk (>=0.5.0,<0.6.0)
19
+ Requires-Dist: openfeature-sdk (>=0.5.0,<0.8.0)
20
20
  Requires-Dist: pydantic (>=2.5.2,<3.0.0)
21
21
  Requires-Dist: pylru (>=1.2.1,<2.0.0)
22
22
  Requires-Dist: rel (>=0.4.9,<0.5.0)
@@ -18,13 +18,12 @@ from openfeature.exception import (
18
18
  from openfeature.flag_evaluation import FlagResolutionDetails, Reason
19
19
  from openfeature.hook import Hook
20
20
  from openfeature.provider.metadata import Metadata
21
- from openfeature.provider.provider import AbstractProvider
21
+ from openfeature.provider import AbstractProvider
22
22
  from pydantic import PrivateAttr, ValidationError
23
23
 
24
24
  from gofeatureflag_python_provider.data_collector_hook import DataCollectorHook
25
25
  from gofeatureflag_python_provider.metadata import GoFeatureFlagMetadata
26
26
  from gofeatureflag_python_provider.options import BaseModel, GoFeatureFlagOptions
27
- from gofeatureflag_python_provider.provider_status import ProviderStatus
28
27
  from gofeatureflag_python_provider.request_flag_evaluation import (
29
28
  RequestFlagEvaluation,
30
29
  convert_evaluation_context,
@@ -46,7 +45,6 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
46
45
  options: GoFeatureFlagOptions
47
46
  _http_client: urllib3.PoolManager = PrivateAttr()
48
47
  _cache: pylru.lrucache = PrivateAttr()
49
- _status: ProviderStatus = PrivateAttr(ProviderStatus.NOT_READY)
50
48
  _data_collector_hook: Optional[DataCollectorHook] = PrivateAttr()
51
49
  _ws: websocket.WebSocketApp = PrivateAttr()
52
50
  _ws_thread: Thread = PrivateAttr()
@@ -75,18 +73,8 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
75
73
  self._ws = websocket.WebSocketApp(
76
74
  self._build_websocket_uri(),
77
75
  on_message=self._websocket_message_handler,
78
- on_open=self._websocket_open_handler,
79
- on_close=self._websocket_close_handler,
80
- on_error=self._websocket_error_handler,
81
76
  )
82
77
 
83
- def get_status(self) -> ProviderStatus:
84
- """
85
- get_status returns the status of the provider
86
- :return: the status of the provider
87
- """
88
- return self._status
89
-
90
78
  def initialize(self, evaluation_context: EvaluationContext) -> None:
91
79
  """
92
80
  initialize is called when the provider is initialized.
@@ -99,8 +87,6 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
99
87
  if self.options.disable_cache_invalidation is False:
100
88
  self._ws_thread = Thread(target=self.run_websocket)
101
89
  self._ws_thread.start()
102
- else:
103
- self._status = ProviderStatus.READY
104
90
 
105
91
  def shutdown(self):
106
92
  if self.options.disable_cache_invalidation is False:
@@ -114,8 +100,6 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
114
100
  self._data_collector_hook.shutdown()
115
101
  self._data_collector_hook = None
116
102
 
117
- self._status = ProviderStatus.NOT_READY
118
-
119
103
  def get_metadata(self) -> Metadata:
120
104
  return GoFeatureFlagMetadata()
121
105
 
@@ -192,14 +176,6 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
192
176
  :return: a FlagResolutionDetails object containing the response for the SDK.
193
177
  """
194
178
  try:
195
- if self._status != ProviderStatus.READY:
196
- return FlagResolutionDetails[original_type](
197
- value=default_value,
198
- reason=Reason.ERROR,
199
- error_code=ErrorCode.PROVIDER_NOT_READY,
200
- error_message="GO Feature Flag provider is not ready",
201
- )
202
-
203
179
  goff_evaluation_context = convert_evaluation_context(evaluation_context)
204
180
  goff_request = RequestFlagEvaluation(
205
181
  user=goff_evaluation_context,
@@ -310,32 +286,5 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
310
286
  # when we receive a message from go-feature-flag server, we clear the cache.
311
287
  self._cache.clear()
312
288
 
313
- def _websocket_open_handler(self, ws_app) -> None:
314
- """
315
- websocket_open_handler is the handler called when the websocket is open
316
- :param ws app: the websocket app
317
- :return: None
318
- """
319
- self._status = ProviderStatus.READY
320
-
321
- def _websocket_error_handler(self, ws_app, error) -> None:
322
- """
323
- websocket_error_handler is the handler called when we receive an error from the GO Feature Flag server
324
- :param ws_app: the websocket app
325
- :param error: error received
326
- :return: None
327
- """
328
- self._status = ProviderStatus.ERROR
329
-
330
- def _websocket_close_handler(self, ws_app, close_status_code, close_msg) -> None:
331
- """
332
- websocket_close_handler is the handler called when the websocket is closed
333
- :param wsapp: the websocket app
334
- :param close_status_code: the status code of the close
335
- :param close_msg: the message of the close
336
- :return: None
337
- """
338
- self._status = ProviderStatus.STALE
339
-
340
289
  def __hash__(self):
341
290
  return id(self)
@@ -1,4 +1,4 @@
1
- from typing import Optional, Generic, Union, TypeVar
1
+ from typing import Optional, Union, TypeVar
2
2
  from gofeatureflag_python_provider.options import BaseModel
3
3
 
4
4
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "gofeatureflag-python-provider"
3
- version = "0.1.2"
3
+ version = "0.2.0"
4
4
  description = "GO Feature Flag provider for OpenFeature"
5
5
  license = "Apache-2.0"
6
6
  authors = [ "Thomas Poignant" ]
@@ -28,7 +28,7 @@ classifiers = [
28
28
 
29
29
  [tool.poetry.dependencies]
30
30
  python = "^3.9"
31
- openfeature-sdk = ">=0.5.0,<0.6.0"
31
+ openfeature-sdk = ">=0.5.0,<0.8.0"
32
32
  pydantic = "^2.5.2"
33
33
  urllib3 = "^2.1.0"
34
34
  pylru = "^1.2.1"
@@ -1,9 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- # ProviderStatus is an enum that represents the status of a provider
5
- class ProviderStatus(Enum):
6
- NOT_READY = 1
7
- READY = 2
8
- STALE = 3
9
- ERROR = 4