gofeatureflag-python-provider 0.4.4__tar.gz → 0.5.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
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: gofeatureflag-python-provider
3
- Version: 0.4.4
3
+ Version: 0.5.0
4
4
  Summary: GO Feature Flag provider for OpenFeature
5
5
  License: Apache-2.0
6
6
  Keywords: feature flags,feature toggles,go-feature-flag,gofeatureflag,openfeature,open-feature
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
16
17
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
18
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
19
  Requires-Dist: openfeature-sdk (>=0.5.0,<0.9.0)
@@ -30,7 +31,7 @@ Description-Content-Type: text/markdown
30
31
 
31
32
  # GO Feature Flag Python Provider
32
33
 
33
- GO Feature Flag provider allows you to connect to your GO Feature Flag instance.
34
+ GO Feature Flag provider allows you to connect to your GO Feature Flag instance.
34
35
 
35
36
  [GO Feature Flag](https://gofeatureflag.org) believes in simplicity and offers a simple and lightweight solution to use feature flags.
36
37
  Our focus is to avoid any complex infrastructure work to use GO Feature Flag.
@@ -71,9 +72,8 @@ client = api.get_client(domain="test-client")
71
72
 
72
73
  This code block explains how you can create an `EvaluationContext` and use it to evaluate your flag.
73
74
 
74
-
75
75
  > In this example we are evaluating a `boolean` flag, but other types are available.
76
- >
76
+ >
77
77
  > **Refer to the [Open Feature documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api#basic-evaluation) to know more about it.**
78
78
 
79
79
  ```python
@@ -99,7 +99,7 @@ admin_flag = client.get_boolean_value(
99
99
  default_value=default_value,
100
100
  evaluation_context=ctx,
101
101
  )
102
-
102
+
103
103
  if admin_flag:
104
104
  # flag "flag-only-for-admin" is true for the user
105
105
  else:
@@ -1,6 +1,6 @@
1
1
  # GO Feature Flag Python Provider
2
2
 
3
- GO Feature Flag provider allows you to connect to your GO Feature Flag instance.
3
+ GO Feature Flag provider allows you to connect to your GO Feature Flag instance.
4
4
 
5
5
  [GO Feature Flag](https://gofeatureflag.org) believes in simplicity and offers a simple and lightweight solution to use feature flags.
6
6
  Our focus is to avoid any complex infrastructure work to use GO Feature Flag.
@@ -41,9 +41,8 @@ client = api.get_client(domain="test-client")
41
41
 
42
42
  This code block explains how you can create an `EvaluationContext` and use it to evaluate your flag.
43
43
 
44
-
45
44
  > In this example we are evaluating a `boolean` flag, but other types are available.
46
- >
45
+ >
47
46
  > **Refer to the [Open Feature documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api#basic-evaluation) to know more about it.**
48
47
 
49
48
  ```python
@@ -69,7 +68,7 @@ admin_flag = client.get_boolean_value(
69
68
  default_value=default_value,
70
69
  evaluation_context=ctx,
71
70
  )
72
-
71
+
73
72
  if admin_flag:
74
73
  # flag "flag-only-for-admin" is true for the user
75
74
  else:
@@ -1,5 +1,4 @@
1
1
  import datetime
2
- import threading
3
2
  import time
4
3
  import urllib3
5
4
  from gofeatureflag_python_provider.options import GoFeatureFlagOptions
@@ -10,6 +9,7 @@ from gofeatureflag_python_provider.request_data_collector import (
10
9
  from http import HTTPStatus
11
10
  from openfeature.flag_evaluation import FlagEvaluationDetails, Reason
12
11
  from openfeature.hook import Hook, HookContext
12
+ from threading import Thread, Event
13
13
  from typing import Optional
14
14
  from urllib.parse import urljoin
15
15
 
@@ -18,9 +18,9 @@ default_targeting_key = "undefined-targetingKey"
18
18
 
19
19
  class DataCollectorHook(Hook):
20
20
  # _thread_stopper is used to stop the background task when we shut down the hook
21
- _thread_stopper: bool = True
21
+ _thread_stopper: Optional[Event] = None
22
22
  # _thread_data_collector is the thread used to call the relay proxy to collect data
23
- _thread_data_collector: threading.Thread = None
23
+ _thread_data_collector: Optional[Thread] = None
24
24
  # _options is the options of the provider
25
25
  _options: Optional[GoFeatureFlagOptions] = None
26
26
  # _data_collector_endpoint is the endpoint of the relay proxy
@@ -34,7 +34,7 @@ class DataCollectorHook(Hook):
34
34
 
35
35
  def __init__(self, options: GoFeatureFlagOptions, http_client: urllib3.PoolManager):
36
36
  self._http_client = http_client
37
- self._thread_data_collector = threading.Thread(target=self.background_task)
37
+ self._thread_data_collector = Thread(target=self.background_task, daemon=True)
38
38
  self._options = options
39
39
  self._data_collector_endpoint = urljoin(
40
40
  str(self._options.endpoint), "/v1/data/collector"
@@ -88,21 +88,19 @@ class DataCollectorHook(Hook):
88
88
 
89
89
  def initialize(self):
90
90
  self._event_queue = []
91
- self._thread_stopper = False
91
+ self._thread_stopper = Event()
92
92
  self._thread_data_collector.start()
93
93
 
94
94
  def shutdown(self):
95
95
  # setting the _thread_stopper to True will stop the background task
96
- self._thread_stopper = True
96
+ self._thread_stopper.set()
97
97
  self._thread_data_collector.join()
98
98
  self._collect_data()
99
- self._thread_stopper = False
100
- self._event_queue = []
101
99
 
102
100
  def background_task(self):
103
- while not self._thread_stopper:
101
+ while not self._thread_stopper.is_set():
104
102
  waiting_time = self._options.data_flush_interval / 1000
105
- time.sleep(waiting_time)
103
+ self._thread_stopper.wait(waiting_time)
106
104
  self._collect_data()
107
105
 
108
106
  def _collect_data(self):
@@ -1,3 +1,4 @@
1
+ import atexit
1
2
  import json
2
3
  import pylru
3
4
  import urllib3
@@ -88,8 +89,9 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
88
89
  self._data_collector_hook.initialize()
89
90
  # start the websocket thread
90
91
  if self.options.disable_cache_invalidation is False:
91
- self._ws_thread = Thread(target=self.run_websocket)
92
+ self._ws_thread = Thread(target=self.run_websocket, daemon=True)
92
93
  self._ws_thread.start()
94
+ atexit.register(self.shutdown)
93
95
 
94
96
  def shutdown(self):
95
97
  if self.options.disable_cache_invalidation is False:
@@ -0,0 +1,41 @@
1
+ [tool.poetry]
2
+ name = "gofeatureflag-python-provider"
3
+ version = "0.5.0"
4
+ description = "GO Feature Flag provider for OpenFeature"
5
+ license = "Apache-2.0"
6
+ authors = ["Thomas Poignant"]
7
+ readme = "README.md"
8
+ homepage = "https://gofeatureflag.org"
9
+ repository = "https://github.com/thomaspoignant/go-feature-flag"
10
+ documentation = "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider"
11
+ keywords = ["feature flags", "feature toggles", "go-feature-flag", "gofeatureflag", "openfeature", "open-feature"]
12
+ classifiers = [
13
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
14
+ "Topic :: Software Development :: Libraries :: Python Modules"
15
+ ]
16
+
17
+ [tool.poetry.urls]
18
+ "Bug Tracker" = "https://github.com/thomaspoignant/go-feature-flag/issues"
19
+ "Source Code" = "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider"
20
+ Documentation = "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider"
21
+
22
+
23
+ [tool.poetry.dependencies]
24
+ python = "^3.9"
25
+ openfeature-sdk = ">=0.5.0,<0.9.0"
26
+ pydantic = "^2.5.2"
27
+ urllib3 = "^2.1.0"
28
+ pylru = "^1.2.1"
29
+ websocket-client = "^1.6.4"
30
+ rel = "^0.4.9"
31
+
32
+ [tool.poetry.group.dev.dependencies]
33
+ pytest = ">=7.4,<9.0"
34
+ black = ">=23.10.1,<26.0.0"
35
+ requests = "^2.31.0"
36
+ pyyaml = "^6.0.1"
37
+ pytest-docker = ">=2.0.1,<4.0.0"
38
+
39
+ [build-system]
40
+ requires = ["poetry-core>=1.0.0"]
41
+ build-backend = "poetry.core.masonry.api"
@@ -1 +0,0 @@
1
- __version__ = "0.1.0"
@@ -1,47 +0,0 @@
1
- [tool.poetry]
2
- name = "gofeatureflag-python-provider"
3
- version = "0.4.4"
4
- description = "GO Feature Flag provider for OpenFeature"
5
- license = "Apache-2.0"
6
- authors = [ "Thomas Poignant" ]
7
- readme = "README.md"
8
- homepage = "https://gofeatureflag.org"
9
- repository = "https://github.com/thomaspoignant/go-feature-flag"
10
- documentation = "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider"
11
- keywords = [
12
- "feature flags",
13
- "feature toggles",
14
- "go-feature-flag",
15
- "gofeatureflag",
16
- "openfeature",
17
- "open-feature"
18
- ]
19
- classifiers = [
20
- "Topic :: Software Development :: Libraries :: Application Frameworks",
21
- "Topic :: Software Development :: Libraries :: Python Modules"
22
- ]
23
-
24
- [tool.poetry.urls]
25
- "Bug Tracker" = "https://github.com/thomaspoignant/go-feature-flag/issues"
26
- "Source Code" = "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider"
27
- Documentation = "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider"
28
-
29
- [tool.poetry.dependencies]
30
- python = "^3.9"
31
- openfeature-sdk = ">=0.5.0,<0.9.0"
32
- pydantic = "^2.5.2"
33
- urllib3 = "^2.1.0"
34
- pylru = "^1.2.1"
35
- websocket-client = "^1.6.4"
36
- rel = "^0.4.9"
37
-
38
- [tool.poetry.group.dev.dependencies]
39
- pytest = ">=7.4,<9.0"
40
- black = ">=23.10.1,<26.0.0"
41
- requests = "^2.31.0"
42
- pyyaml = "^6.0.1"
43
- pytest-docker = ">=2.0.1,<4.0.0"
44
-
45
- [build-system]
46
- requires = [ "poetry-core>=1.0.0" ]
47
- build-backend = "poetry.core.masonry.api"