openfeature-go-feature-flag-provider 0.1.7 → 0.1.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/openfeature/go-feature-flag/client/common.rb +25 -7
- data/lib/openfeature/go-feature-flag/client/http_api.rb +5 -7
- data/lib/openfeature/go-feature-flag/client/unix_api.rb +12 -9
- data/lib/openfeature/go-feature-flag/go_feature_flag_provider.rb +1 -1
- data/lib/openfeature/go-feature-flag/options.rb +3 -2
- data/lib/openfeature/go-feature-flag/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0838c9664ebeca1013f90b3cc70c4beb1c42e5c7725b59b4a097a6be19662560'
|
|
4
|
+
data.tar.gz: a18db33dd6dd0d7be19cc9dbba2e30953c68e4b6ebcdf3ebde1a5e4fa1e15052
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6316d172b0d13e9900f3b31e20068fb80407feb9df3949bbeccf4b9eac29efdba2feb67ac5f2f45483d323302cbb8ead84d753b4199f409a4b14c186329f78bf
|
|
7
|
+
data.tar.gz: 8b3cc0c468d82c86fb6121430085dafd9f49c0c511bee805d4c39114927f92aedea2b6e71385b4dd8a3d28665719985cbcc7c97785cff10d5c3dcae9f6364d3f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.9](https://github.com/open-feature/ruby-sdk-contrib/compare/openfeature-go-feature-flag-provider/v0.1.8...openfeature-go-feature-flag-provider/v0.1.9) (2026-01-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ✨ New Features
|
|
7
|
+
|
|
8
|
+
* Timeout option for http client ([#76](https://github.com/open-feature/ruby-sdk-contrib/issues/76)) ([11e0de2](https://github.com/open-feature/ruby-sdk-contrib/commit/11e0de297527e90ee3dfcabf9d6bc35ff3149b9b))
|
|
9
|
+
|
|
10
|
+
## [0.1.8](https://github.com/open-feature/ruby-sdk-contrib/compare/openfeature-go-feature-flag-provider/v0.1.7...openfeature-go-feature-flag-provider/v0.1.8) (2026-01-13)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
* Make goff unix socket client thread safe ([#74](https://github.com/open-feature/ruby-sdk-contrib/issues/74)) ([ec25c37](https://github.com/open-feature/ruby-sdk-contrib/commit/ec25c3787b108ed2af8d7f1c9efbd6a258870a21))
|
|
16
|
+
|
|
3
17
|
## [0.1.7](https://github.com/open-feature/ruby-sdk-contrib/compare/openfeature-go-feature-flag-provider/v0.1.6...openfeature-go-feature-flag-provider/v0.1.7) (2025-11-19)
|
|
4
18
|
|
|
5
19
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -50,6 +50,7 @@ The `OpenFeature::GoFeatureFlag::Provider` needs some options to be created and
|
|
|
50
50
|
| `endpoint` | **(mandatory)** The URL to access to the relay-proxy.<br />*(example: `https://relay.proxy.gofeatureflag.org/`)* |
|
|
51
51
|
| `headers` | A `Hash` object containing the headers to send to the relay-proxy.<br/>*(example to send APIKey: `{"Authorization" => "Bearer my-api-key"}` |
|
|
52
52
|
| `instrumentation` | [Faraday instrumentation](https://github.com/lostisland/faraday/blob/main/docs/middleware/included/instrumentation.md) hash |
|
|
53
|
+
| `timeout` | Request timeout in seconds ([Faraday request options](https://rubydoc.info/github/lostisland/faraday/Faraday/Connection)). |
|
|
53
54
|
The only required option to create a `GoFeatureFlagProvider` is the URL _(`endpoint`)_ to your GO Feature Flag relay-proxy instance.
|
|
54
55
|
|
|
55
56
|
```ruby
|
|
@@ -24,8 +24,20 @@ module OpenFeature
|
|
|
24
24
|
{"Content-Type" => "application/json"}.merge(@custom_headers || {})
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def evaluation_request(evaluation_context)
|
|
28
|
+
ctx = evaluation_context || OpenFeature::SDK::EvaluationContext.new
|
|
29
|
+
fields = ctx.fields.dup
|
|
30
|
+
# replace targeting_key by targetingKey without mutating original fields
|
|
31
|
+
fields["targetingKey"] = ctx.targeting_key
|
|
32
|
+
fields.delete("targeting_key")
|
|
33
|
+
|
|
34
|
+
{context: fields}
|
|
35
|
+
end
|
|
36
|
+
|
|
27
37
|
def check_retry_after
|
|
28
|
-
|
|
38
|
+
lock = (@retry_lock ||= Mutex.new)
|
|
39
|
+
lock.synchronize do
|
|
40
|
+
return if @retry_after.nil?
|
|
29
41
|
if Time.now < @retry_after
|
|
30
42
|
raise OpenFeature::GoFeatureFlag::RateLimited.new(nil)
|
|
31
43
|
else
|
|
@@ -109,12 +121,18 @@ module OpenFeature
|
|
|
109
121
|
return nil if retry_after.nil?
|
|
110
122
|
|
|
111
123
|
begin
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
next_retry_time =
|
|
125
|
+
if /^\d+$/.match?(retry_after)
|
|
126
|
+
# Retry-After is in seconds
|
|
127
|
+
Time.now + Integer(retry_after)
|
|
128
|
+
else
|
|
129
|
+
# Retry-After is an HTTP-date
|
|
130
|
+
Time.httpdate(retry_after)
|
|
131
|
+
end
|
|
132
|
+
# Protect updates and never shorten an existing backoff window
|
|
133
|
+
lock = (@retry_lock ||= Mutex.new)
|
|
134
|
+
lock.synchronize do
|
|
135
|
+
@retry_after = [@retry_after, next_retry_time].compact.max
|
|
118
136
|
end
|
|
119
137
|
rescue ArgumentError
|
|
120
138
|
# ignore invalid Retry-After header
|
|
@@ -7,9 +7,10 @@ module OpenFeature
|
|
|
7
7
|
module GoFeatureFlag
|
|
8
8
|
module Client
|
|
9
9
|
class HttpApi < Common
|
|
10
|
-
def initialize(endpoint: nil, custom_headers: nil, instrumentation: nil)
|
|
10
|
+
def initialize(endpoint: nil, custom_headers: nil, instrumentation: nil, timeout: nil)
|
|
11
11
|
@custom_headers = custom_headers
|
|
12
|
-
|
|
12
|
+
request_options = {timeout: timeout}
|
|
13
|
+
@faraday_connection = Faraday.new(url: endpoint, headers: headers, request: request_options) do |f|
|
|
13
14
|
f.request :instrumentation, instrumentation if instrumentation
|
|
14
15
|
f.adapter :net_http_persistent do |http|
|
|
15
16
|
http.idle_timeout = 30
|
|
@@ -19,13 +20,10 @@ module OpenFeature
|
|
|
19
20
|
|
|
20
21
|
def evaluate_ofrep_api(flag_key:, evaluation_context:)
|
|
21
22
|
check_retry_after
|
|
22
|
-
|
|
23
|
-
# replace targeting_key by targetingKey
|
|
24
|
-
evaluation_context.fields["targetingKey"] = evaluation_context.targeting_key
|
|
25
|
-
evaluation_context.fields.delete("targeting_key")
|
|
23
|
+
request = evaluation_request(evaluation_context)
|
|
26
24
|
|
|
27
25
|
response = @faraday_connection.post("/ofrep/v1/evaluate/flags/#{flag_key}") do |req|
|
|
28
|
-
req.body =
|
|
26
|
+
req.body = request.to_json
|
|
29
27
|
end
|
|
30
28
|
|
|
31
29
|
case response.status
|
|
@@ -7,21 +7,17 @@ module OpenFeature
|
|
|
7
7
|
module GoFeatureFlag
|
|
8
8
|
module Client
|
|
9
9
|
class UnixApi < Common
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def initialize(endpoint: nil, custom_headers: nil)
|
|
10
|
+
def initialize(endpoint: nil, custom_headers: nil, unix_socket_client_factory: nil)
|
|
13
11
|
@custom_headers = custom_headers
|
|
14
|
-
@
|
|
12
|
+
@endpoint = endpoint
|
|
13
|
+
@unix_socket_client_factory = unix_socket_client_factory || ->(ep) { HttpUnix.new(ep) }
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
def evaluate_ofrep_api(flag_key:, evaluation_context:)
|
|
18
17
|
check_retry_after
|
|
19
|
-
evaluation_context = OpenFeature::SDK::EvaluationContext.new if evaluation_context.nil?
|
|
20
|
-
# replace targeting_key by targetingKey
|
|
21
|
-
evaluation_context.fields["targetingKey"] = evaluation_context.targeting_key
|
|
22
|
-
evaluation_context.fields.delete("targeting_key")
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
request = evaluation_request(evaluation_context)
|
|
20
|
+
response = thread_local_socket.post("/ofrep/v1/evaluate/flags/#{flag_key}", request, headers)
|
|
25
21
|
|
|
26
22
|
case response.code
|
|
27
23
|
when "200"
|
|
@@ -39,6 +35,13 @@ module OpenFeature
|
|
|
39
35
|
raise OpenFeature::GoFeatureFlag::InternalServerError.new(response)
|
|
40
36
|
end
|
|
41
37
|
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def thread_local_socket
|
|
42
|
+
key = "openfeature_goff_unix_socket_#{object_id}"
|
|
43
|
+
Thread.current[key] ||= @unix_socket_client_factory.call(@endpoint)
|
|
44
|
+
end
|
|
42
45
|
end
|
|
43
46
|
end
|
|
44
47
|
end
|
|
@@ -103,7 +103,7 @@ module OpenFeature
|
|
|
103
103
|
def build_client(options)
|
|
104
104
|
case options.type
|
|
105
105
|
when "http"
|
|
106
|
-
Client::HttpApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers, instrumentation: options.instrumentation)
|
|
106
|
+
Client::HttpApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers, instrumentation: options.instrumentation, timeout: options.timeout)
|
|
107
107
|
when "unix"
|
|
108
108
|
Client::UnixApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers)
|
|
109
109
|
else
|
|
@@ -6,9 +6,9 @@ module OpenFeature
|
|
|
6
6
|
module GoFeatureFlag
|
|
7
7
|
# This class is the configuration class for the GoFeatureFlagProvider
|
|
8
8
|
class Options
|
|
9
|
-
attr_accessor :endpoint, :custom_headers, :exporter_metadata, :instrumentation, :type
|
|
9
|
+
attr_accessor :endpoint, :custom_headers, :exporter_metadata, :instrumentation, :type, :timeout
|
|
10
10
|
|
|
11
|
-
def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentation: nil, type: "http")
|
|
11
|
+
def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentation: nil, type: "http", timeout: nil)
|
|
12
12
|
validate_endpoint(endpoint, type)
|
|
13
13
|
validate_instrumentation(instrumentation: instrumentation)
|
|
14
14
|
@type = type
|
|
@@ -16,6 +16,7 @@ module OpenFeature
|
|
|
16
16
|
@custom_headers = headers
|
|
17
17
|
@exporter_metadata = exporter_metadata
|
|
18
18
|
@instrumentation = instrumentation
|
|
19
|
+
@timeout = timeout
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
private
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openfeature-go-feature-flag-provider
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Poignant
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: openfeature-sdk
|