gofeatureflag-python-provider 0.1.1__tar.gz → 0.1.2__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.
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/PKG-INFO +7 -7
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/README.md +5 -5
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/provider.py +19 -21
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/pyproject.toml +2 -2
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/__init__.py +0 -0
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/data_collector_hook.py +0 -0
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/metadata.py +0 -0
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/options.py +0 -0
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/provider_status.py +0 -0
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/request_data_collector.py +0 -0
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/request_flag_evaluation.py +0 -0
- {gofeatureflag_python_provider-0.1.1 → gofeatureflag_python_provider-0.1.2}/gofeatureflag_python_provider/response_flag_evaluation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: gofeatureflag-python-provider
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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.
|
|
19
|
+
Requires-Dist: openfeature-sdk (>=0.5.0,<0.6.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)
|
|
@@ -58,13 +58,13 @@ from gofeatureflag_python_provider.options import GoFeatureFlagOptions
|
|
|
58
58
|
from openfeature import api
|
|
59
59
|
from openfeature.evaluation_context import EvaluationContext
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
# ...
|
|
62
62
|
|
|
63
63
|
goff_provider = GoFeatureFlagProvider(
|
|
64
64
|
options=GoFeatureFlagOptions(endpoint="https://gofeatureflag.org/")
|
|
65
65
|
)
|
|
66
66
|
api.set_provider(goff_provider)
|
|
67
|
-
client = api.get_client(
|
|
67
|
+
client = api.get_client(domain="test-client")
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
## Evaluate your flag
|
|
@@ -76,9 +76,9 @@ This code block explains how you can create an `EvaluationContext` and use it to
|
|
|
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
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
```python
|
|
80
|
+
# Context of your flag evaluation.
|
|
81
|
+
# With GO Feature Flag you MUST have a targetingKey that is a unique identifier of the user.
|
|
82
82
|
evaluation_ctx = EvaluationContext(
|
|
83
83
|
targeting_key="d45e303a-38c2-11ed-a261-0242ac120002",
|
|
84
84
|
attributes={
|
|
@@ -28,13 +28,13 @@ from gofeatureflag_python_provider.options import GoFeatureFlagOptions
|
|
|
28
28
|
from openfeature import api
|
|
29
29
|
from openfeature.evaluation_context import EvaluationContext
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
# ...
|
|
32
32
|
|
|
33
33
|
goff_provider = GoFeatureFlagProvider(
|
|
34
34
|
options=GoFeatureFlagOptions(endpoint="https://gofeatureflag.org/")
|
|
35
35
|
)
|
|
36
36
|
api.set_provider(goff_provider)
|
|
37
|
-
client = api.get_client(
|
|
37
|
+
client = api.get_client(domain="test-client")
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Evaluate your flag
|
|
@@ -46,9 +46,9 @@ This code block explains how you can create an `EvaluationContext` and use it to
|
|
|
46
46
|
>
|
|
47
47
|
> **Refer to the [Open Feature documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api#basic-evaluation) to know more about it.**
|
|
48
48
|
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
```python
|
|
50
|
+
# Context of your flag evaluation.
|
|
51
|
+
# With GO Feature Flag you MUST have a targetingKey that is a unique identifier of the user.
|
|
52
52
|
evaluation_ctx = EvaluationContext(
|
|
53
53
|
targeting_key="d45e303a-38c2-11ed-a261-0242ac120002",
|
|
54
54
|
attributes={
|
|
@@ -8,32 +8,30 @@ import pylru
|
|
|
8
8
|
import urllib3
|
|
9
9
|
import websocket
|
|
10
10
|
from openfeature.evaluation_context import EvaluationContext
|
|
11
|
-
from openfeature.exception import ErrorCode
|
|
12
11
|
from openfeature.exception import (
|
|
12
|
+
ErrorCode,
|
|
13
13
|
FlagNotFoundError,
|
|
14
|
-
TypeMismatchError,
|
|
15
14
|
GeneralError,
|
|
16
15
|
OpenFeatureError,
|
|
16
|
+
TypeMismatchError,
|
|
17
17
|
)
|
|
18
|
-
from openfeature.flag_evaluation import
|
|
19
|
-
from openfeature.flag_evaluation import Reason
|
|
18
|
+
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
|
|
20
19
|
from openfeature.hook import Hook
|
|
21
20
|
from openfeature.provider.metadata import Metadata
|
|
22
21
|
from openfeature.provider.provider import AbstractProvider
|
|
23
|
-
from pydantic import
|
|
22
|
+
from pydantic import PrivateAttr, ValidationError
|
|
24
23
|
|
|
25
24
|
from gofeatureflag_python_provider.data_collector_hook import DataCollectorHook
|
|
26
25
|
from gofeatureflag_python_provider.metadata import GoFeatureFlagMetadata
|
|
27
|
-
from gofeatureflag_python_provider.options import BaseModel
|
|
28
|
-
from gofeatureflag_python_provider.options import GoFeatureFlagOptions
|
|
26
|
+
from gofeatureflag_python_provider.options import BaseModel, GoFeatureFlagOptions
|
|
29
27
|
from gofeatureflag_python_provider.provider_status import ProviderStatus
|
|
30
28
|
from gofeatureflag_python_provider.request_flag_evaluation import (
|
|
31
29
|
RequestFlagEvaluation,
|
|
32
30
|
convert_evaluation_context,
|
|
33
31
|
)
|
|
34
32
|
from gofeatureflag_python_provider.response_flag_evaluation import (
|
|
35
|
-
ResponseFlagEvaluation,
|
|
36
33
|
JsonType,
|
|
34
|
+
ResponseFlagEvaluation,
|
|
37
35
|
)
|
|
38
36
|
|
|
39
37
|
AbstractProviderMetaclass = type(AbstractProvider)
|
|
@@ -131,7 +129,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
131
129
|
flag_key: str,
|
|
132
130
|
default_value: bool,
|
|
133
131
|
evaluation_context: Optional[EvaluationContext] = None,
|
|
134
|
-
) ->
|
|
132
|
+
) -> FlagResolutionDetails[bool]:
|
|
135
133
|
return self.generic_go_feature_flag_resolver(
|
|
136
134
|
bool, flag_key, default_value, evaluation_context
|
|
137
135
|
)
|
|
@@ -141,7 +139,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
141
139
|
flag_key: str,
|
|
142
140
|
default_value: str,
|
|
143
141
|
evaluation_context: Optional[EvaluationContext] = None,
|
|
144
|
-
) ->
|
|
142
|
+
) -> FlagResolutionDetails[str]:
|
|
145
143
|
return self.generic_go_feature_flag_resolver(
|
|
146
144
|
str, flag_key, default_value, evaluation_context
|
|
147
145
|
)
|
|
@@ -151,7 +149,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
151
149
|
flag_key: str,
|
|
152
150
|
default_value: int,
|
|
153
151
|
evaluation_context: Optional[EvaluationContext] = None,
|
|
154
|
-
) ->
|
|
152
|
+
) -> FlagResolutionDetails[int]:
|
|
155
153
|
return self.generic_go_feature_flag_resolver(
|
|
156
154
|
int, flag_key, default_value, evaluation_context
|
|
157
155
|
)
|
|
@@ -161,7 +159,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
161
159
|
flag_key: str,
|
|
162
160
|
default_value: float,
|
|
163
161
|
evaluation_context: Optional[EvaluationContext] = None,
|
|
164
|
-
) ->
|
|
162
|
+
) -> FlagResolutionDetails[float]:
|
|
165
163
|
return self.generic_go_feature_flag_resolver(
|
|
166
164
|
float, flag_key, default_value, evaluation_context
|
|
167
165
|
)
|
|
@@ -171,7 +169,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
171
169
|
flag_key: str,
|
|
172
170
|
default_value: dict,
|
|
173
171
|
evaluation_context: Optional[EvaluationContext] = None,
|
|
174
|
-
) ->
|
|
172
|
+
) -> FlagResolutionDetails[Union[list, dict]]:
|
|
175
173
|
return self.generic_go_feature_flag_resolver(
|
|
176
174
|
Union[dict, list], flag_key, default_value, evaluation_context
|
|
177
175
|
)
|
|
@@ -182,7 +180,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
182
180
|
flag_key: str,
|
|
183
181
|
default_value: JsonType,
|
|
184
182
|
evaluation_context: Optional[EvaluationContext] = None,
|
|
185
|
-
) ->
|
|
183
|
+
) -> FlagResolutionDetails[JsonType]:
|
|
186
184
|
"""
|
|
187
185
|
generic_go_feature_flag_resolver is a generic evaluations of your flag with GO Feature Flag relay proxy it works
|
|
188
186
|
with all types.
|
|
@@ -191,12 +189,11 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
191
189
|
:param flag_key: name of the flag
|
|
192
190
|
:param default_value: default value of the flag
|
|
193
191
|
:param evaluation_context: context to evaluate the flag
|
|
194
|
-
:return: a
|
|
192
|
+
:return: a FlagResolutionDetails object containing the response for the SDK.
|
|
195
193
|
"""
|
|
196
194
|
try:
|
|
197
195
|
if self._status != ProviderStatus.READY:
|
|
198
|
-
return
|
|
199
|
-
flag_key=flag_key,
|
|
196
|
+
return FlagResolutionDetails[original_type](
|
|
200
197
|
value=default_value,
|
|
201
198
|
reason=Reason.ERROR,
|
|
202
199
|
error_code=ErrorCode.PROVIDER_NOT_READY,
|
|
@@ -252,8 +249,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
252
249
|
)
|
|
253
250
|
|
|
254
251
|
if response_flag_evaluation.reason == Reason.DISABLED.value:
|
|
255
|
-
return
|
|
256
|
-
flag_key=flag_key,
|
|
252
|
+
return FlagResolutionDetails[original_type](
|
|
257
253
|
value=default_value,
|
|
258
254
|
reason=Reason.DISABLED,
|
|
259
255
|
)
|
|
@@ -263,8 +259,7 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
263
259
|
"flag {} was not found in your configuration".format(flag_key)
|
|
264
260
|
)
|
|
265
261
|
|
|
266
|
-
return
|
|
267
|
-
flag_key=flag_key,
|
|
262
|
+
return FlagResolutionDetails[original_type](
|
|
268
263
|
value=response_flag_evaluation.value,
|
|
269
264
|
variant=response_flag_evaluation.variationType,
|
|
270
265
|
reason=(
|
|
@@ -341,3 +336,6 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
341
336
|
:return: None
|
|
342
337
|
"""
|
|
343
338
|
self._status = ProviderStatus.STALE
|
|
339
|
+
|
|
340
|
+
def __hash__(self):
|
|
341
|
+
return id(self)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "gofeatureflag-python-provider"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
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 = "
|
|
31
|
+
openfeature-sdk = ">=0.5.0,<0.6.0"
|
|
32
32
|
pydantic = "^2.5.2"
|
|
33
33
|
urllib3 = "^2.1.0"
|
|
34
34
|
pylru = "^1.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|