gofeatureflag-python-provider 0.3.0__tar.gz → 0.4.1__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.3.0 → gofeatureflag_python_provider-0.4.1}/PKG-INFO +3 -3
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/data_collector_hook.py +11 -8
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/options.py +7 -0
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/provider.py +25 -18
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/request_data_collector.py +3 -5
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/request_flag_evaluation.py +3 -4
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/pyproject.toml +2 -2
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/README.md +0 -0
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/__init__.py +0 -0
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/metadata.py +0 -0
- {gofeatureflag_python_provider-0.3.0 → gofeatureflag_python_provider-0.4.1}/gofeatureflag_python_provider/response_flag_evaluation.py +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: gofeatureflag-python-provider
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: GO Feature Flag provider for OpenFeature
|
|
5
|
-
Home-page: https://gofeatureflag.org
|
|
6
5
|
License: Apache-2.0
|
|
7
6
|
Keywords: feature flags,feature toggles,go-feature-flag,gofeatureflag,openfeature,open-feature
|
|
8
7
|
Author: Thomas Poignant
|
|
@@ -25,6 +24,7 @@ Requires-Dist: urllib3 (>=2.1.0,<3.0.0)
|
|
|
25
24
|
Requires-Dist: websocket-client (>=1.6.4,<2.0.0)
|
|
26
25
|
Project-URL: Bug Tracker, https://github.com/thomaspoignant/go-feature-flag/issues
|
|
27
26
|
Project-URL: Documentation, https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider
|
|
27
|
+
Project-URL: Homepage, https://gofeatureflag.org
|
|
28
28
|
Project-URL: Repository, https://github.com/thomaspoignant/go-feature-flag
|
|
29
29
|
Project-URL: Source Code, https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import threading
|
|
3
3
|
import time
|
|
4
|
-
from http import HTTPStatus
|
|
5
|
-
from typing import Optional
|
|
6
|
-
from urllib.parse import urljoin
|
|
7
|
-
|
|
8
4
|
import urllib3
|
|
9
|
-
from openfeature.flag_evaluation import FlagEvaluationDetails, Reason
|
|
10
|
-
from openfeature.hook import Hook, HookContext
|
|
11
|
-
|
|
12
5
|
from gofeatureflag_python_provider.options import GoFeatureFlagOptions
|
|
13
6
|
from gofeatureflag_python_provider.request_data_collector import (
|
|
14
7
|
FeatureEvent,
|
|
15
8
|
RequestDataCollector,
|
|
16
9
|
)
|
|
10
|
+
from http import HTTPStatus
|
|
11
|
+
from openfeature.flag_evaluation import FlagEvaluationDetails, Reason
|
|
12
|
+
from openfeature.hook import Hook, HookContext
|
|
13
|
+
from typing import Optional
|
|
14
|
+
from urllib.parse import urljoin
|
|
17
15
|
|
|
18
16
|
default_targeting_key = "undefined-targetingKey"
|
|
19
17
|
|
|
@@ -31,6 +29,8 @@ class DataCollectorHook(Hook):
|
|
|
31
29
|
_http_client: urllib3.PoolManager = None
|
|
32
30
|
# _data_event_queue is the list of data to collect
|
|
33
31
|
_event_queue: list[FeatureEvent] = []
|
|
32
|
+
# _exporter_metadata is the metadata we send to the GO Feature Flag relay proxy when we report the evaluation data usage.
|
|
33
|
+
_exporter_metadata: dict = {}
|
|
34
34
|
|
|
35
35
|
def __init__(self, options: GoFeatureFlagOptions, http_client: urllib3.PoolManager):
|
|
36
36
|
self._http_client = http_client
|
|
@@ -39,6 +39,9 @@ class DataCollectorHook(Hook):
|
|
|
39
39
|
self._data_collector_endpoint = urljoin(
|
|
40
40
|
str(self._options.endpoint), "/v1/data/collector"
|
|
41
41
|
)
|
|
42
|
+
self._exporter_metadata = options.exporter_metadata
|
|
43
|
+
self._exporter_metadata["provider"] = "python"
|
|
44
|
+
self._exporter_metadata["openfeature"] = True
|
|
42
45
|
|
|
43
46
|
def after(
|
|
44
47
|
self, hook_context: HookContext, details: FlagEvaluationDetails, hints: dict
|
|
@@ -106,7 +109,7 @@ class DataCollectorHook(Hook):
|
|
|
106
109
|
if len(self._event_queue) > 0:
|
|
107
110
|
try:
|
|
108
111
|
goff_request = RequestDataCollector(
|
|
109
|
-
meta=
|
|
112
|
+
meta=self._exporter_metadata,
|
|
110
113
|
events=self._event_queue,
|
|
111
114
|
)
|
|
112
115
|
headers = {"Content-Type": "application/json"}
|
|
@@ -50,3 +50,10 @@ class GoFeatureFlagOptions(BaseModel):
|
|
|
50
50
|
# an API Key to the provider. Please ask the administrator of the relay proxy to provide an API Key.
|
|
51
51
|
# Default: None
|
|
52
52
|
api_key: typing.Optional[str] = None
|
|
53
|
+
|
|
54
|
+
# ExporterMetadata (optional) is the metadata we send to the GO Feature Flag relay proxy when we report the
|
|
55
|
+
# evaluation data usage.
|
|
56
|
+
#
|
|
57
|
+
# ‼️Important: If you are using a GO Feature Flag relay proxy before version v1.41.0, the information of this
|
|
58
|
+
# field will not be added to your feature events.
|
|
59
|
+
exporter_metadata: typing.Optional[dict] = {}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from http import HTTPStatus
|
|
3
|
-
from threading import Thread
|
|
4
|
-
from typing import List, Optional, Type, Union
|
|
5
|
-
from urllib.parse import urljoin
|
|
6
|
-
|
|
7
2
|
import pylru
|
|
8
3
|
import urllib3
|
|
9
4
|
import websocket
|
|
5
|
+
from gofeatureflag_python_provider.data_collector_hook import DataCollectorHook
|
|
6
|
+
from gofeatureflag_python_provider.metadata import GoFeatureFlagMetadata
|
|
7
|
+
from gofeatureflag_python_provider.options import BaseModel, GoFeatureFlagOptions
|
|
8
|
+
from gofeatureflag_python_provider.request_flag_evaluation import (
|
|
9
|
+
RequestFlagEvaluation,
|
|
10
|
+
convert_evaluation_context,
|
|
11
|
+
)
|
|
12
|
+
from gofeatureflag_python_provider.response_flag_evaluation import (
|
|
13
|
+
JsonType,
|
|
14
|
+
ResponseFlagEvaluation,
|
|
15
|
+
)
|
|
16
|
+
from http import HTTPStatus
|
|
10
17
|
from openfeature.evaluation_context import EvaluationContext
|
|
11
18
|
from openfeature.exception import (
|
|
12
19
|
ErrorCode,
|
|
@@ -17,21 +24,11 @@ from openfeature.exception import (
|
|
|
17
24
|
)
|
|
18
25
|
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
|
|
19
26
|
from openfeature.hook import Hook
|
|
20
|
-
from openfeature.provider.metadata import Metadata
|
|
21
27
|
from openfeature.provider import AbstractProvider
|
|
28
|
+
from openfeature.provider.metadata import Metadata
|
|
22
29
|
from pydantic import PrivateAttr, ValidationError
|
|
23
|
-
|
|
24
|
-
from
|
|
25
|
-
from gofeatureflag_python_provider.metadata import GoFeatureFlagMetadata
|
|
26
|
-
from gofeatureflag_python_provider.options import BaseModel, GoFeatureFlagOptions
|
|
27
|
-
from gofeatureflag_python_provider.request_flag_evaluation import (
|
|
28
|
-
RequestFlagEvaluation,
|
|
29
|
-
convert_evaluation_context,
|
|
30
|
-
)
|
|
31
|
-
from gofeatureflag_python_provider.response_flag_evaluation import (
|
|
32
|
-
JsonType,
|
|
33
|
-
ResponseFlagEvaluation,
|
|
34
|
-
)
|
|
30
|
+
from threading import Thread
|
|
31
|
+
from typing import List, Optional, Type, Union
|
|
35
32
|
|
|
36
33
|
AbstractProviderMetaclass = type(AbstractProvider)
|
|
37
34
|
BaseModelMetaclass = type(BaseModel)
|
|
@@ -196,6 +193,16 @@ class GoFeatureFlagProvider(BaseModel, AbstractProvider, metaclass=CombinedMetac
|
|
|
196
193
|
"/v1/feature/{}/eval".format(flag_key),
|
|
197
194
|
)
|
|
198
195
|
|
|
196
|
+
# add exporter metadata to the context if it exists
|
|
197
|
+
if self.options.exporter_metadata:
|
|
198
|
+
goff_request.gofeatureflag["exporterMetadata"] = (
|
|
199
|
+
self.options.exporter_metadata
|
|
200
|
+
)
|
|
201
|
+
goff_request.gofeatureflag["exporterMetadata"]["openfeature"] = True
|
|
202
|
+
goff_request.gofeatureflag["exporterMetadata"][
|
|
203
|
+
"provider"
|
|
204
|
+
] = "python"
|
|
205
|
+
|
|
199
206
|
response = self._http_client.request(
|
|
200
207
|
method="POST",
|
|
201
208
|
url=url,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
from typing import Optional, Any
|
|
2
|
-
|
|
3
|
-
from pydantic import Field, SkipValidation
|
|
4
|
-
|
|
5
1
|
from gofeatureflag_python_provider.options import BaseModel
|
|
2
|
+
from pydantic import Field, SkipValidation
|
|
3
|
+
from typing import Optional, Any, Union
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
class FeatureEvent(BaseModel):
|
|
@@ -47,7 +45,7 @@ class FeatureEvent(BaseModel):
|
|
|
47
45
|
|
|
48
46
|
class RequestDataCollector(BaseModel):
|
|
49
47
|
# Meta are the extra information added to identify who is calling the endpoint.
|
|
50
|
-
meta: Optional[dict[str, str]] = None
|
|
48
|
+
meta: Optional[dict[str, Union[str, int, float, bool]]] = None
|
|
51
49
|
|
|
52
50
|
# Events is the list of the event we send in the payload
|
|
53
51
|
events: list[FeatureEvent] = []
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import json
|
|
3
|
-
from
|
|
4
|
-
|
|
3
|
+
from gofeatureflag_python_provider.options import BaseModel
|
|
5
4
|
from openfeature.evaluation_context import EvaluationContext
|
|
6
5
|
from openfeature.exception import (
|
|
7
6
|
TargetingKeyMissingError,
|
|
8
7
|
InvalidContextError,
|
|
9
8
|
)
|
|
10
9
|
from pydantic import SkipValidation
|
|
11
|
-
|
|
12
|
-
from gofeatureflag_python_provider.options import BaseModel
|
|
10
|
+
from typing import Optional, Any, Dict
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
class GoFeatureFlagEvaluationContext(BaseModel):
|
|
@@ -56,3 +54,4 @@ def convert_evaluation_context(
|
|
|
56
54
|
class RequestFlagEvaluation(BaseModel):
|
|
57
55
|
user: GoFeatureFlagEvaluationContext
|
|
58
56
|
defaultValue: SkipValidation[Any] = None
|
|
57
|
+
gofeatureflag: Optional[Dict] = {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "gofeatureflag-python-provider"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.1"
|
|
4
4
|
description = "GO Feature Flag provider for OpenFeature"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
authors = [ "Thomas Poignant" ]
|
|
@@ -38,7 +38,7 @@ classifiers = [
|
|
|
38
38
|
|
|
39
39
|
[tool.poetry.group.dev.dependencies]
|
|
40
40
|
pytest = ">=7.4,<9.0"
|
|
41
|
-
black = ">=23.10.1,<
|
|
41
|
+
black = ">=23.10.1,<26.0.0"
|
|
42
42
|
requests = "^2.31.0"
|
|
43
43
|
pyyaml = "^6.0.1"
|
|
44
44
|
pytest-docker = ">=2.0.1,<4.0.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|