openfeature-go-feature-flag-provider 0.1.3 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e163ade7d4e9104e049f26e16b2e7541b27f9f4b8b77db8032e7c173cd94cb5
4
- data.tar.gz: aaf8349ce31028f7dce69b3830bde25822fb0a7f9d70b0b7de2707d68cf052b0
3
+ metadata.gz: 732134fec225e4be0564e96bd987f237626269064192544bc5dda5b6b3c870ee
4
+ data.tar.gz: 9419134aad278f0179805d64b2143ed51b735c14141be5a4d3bd92042b71c9a8
5
5
  SHA512:
6
- metadata.gz: 86c42eba61ea314922a0934fe5fbc6bda0939f05707c5d7d201e4c1bc4d3bfc703489d711fdc2ac3119e86077fae79bd79ac0d133b71ad35cd7fe09be0f2c559
7
- data.tar.gz: 1df00ab301c7ad4dc3aa29155610c89c73e6c09f6dc501247a9906760f0d17609751c8d2ea86d9b7c8c252c995fb518e67bbda357a15e2ffd68ef1dca4ec7d5d
6
+ metadata.gz: df6d7ca639d9c1e77eeb2efa0f4cd296766ead410354c4e8c8f89895e0910901062e6ee7def51656c00956c5411c9526d4b572b1b0270332846c42de2e7756ff
7
+ data.tar.gz: bf98ef5871adf51d32118912db5ff9300fe14a666770e511e2ebab4ed4c326af8250722e2081e69fa770635ccb3f6d87b31853281f28a9c39b1a36c73a5ac0a1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.5](https://github.com/open-feature/ruby-sdk-contrib/compare/openfeature-go-feature-flag-provider/v0.1.4...openfeature-go-feature-flag-provider/v0.1.5) (2025-11-04)
4
+
5
+
6
+ ### ✨ New Features
7
+
8
+ * **goff:** add Faraday instrumentation ([#62](https://github.com/open-feature/ruby-sdk-contrib/issues/62)) ([6ae223f](https://github.com/open-feature/ruby-sdk-contrib/commit/6ae223f3ffa076a45581f454cffbc49a0394d871))
9
+
10
+ ## [0.1.4](https://github.com/open-feature/ruby-sdk-contrib/compare/openfeature-go-feature-flag-provider/v0.1.3...openfeature-go-feature-flag-provider/v0.1.4) (2025-07-30)
11
+
12
+
13
+ ### ✨ New Features
14
+
15
+ * connection persistance ([#59](https://github.com/open-feature/ruby-sdk-contrib/issues/59)) ([3a01a5e](https://github.com/open-feature/ruby-sdk-contrib/commit/3a01a5e4cc597aa0bc223e71f3e165f63c66f296))
16
+
3
17
  ## [0.1.3](https://github.com/open-feature/ruby-sdk-contrib/compare/openfeature-go-feature-flag-provider/v0.1.2...openfeature-go-feature-flag-provider/v0.1.3) (2025-01-25)
4
18
 
5
19
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openfeature-go-feature-flag-provider (0.1.3)
5
- faraday (~> 2.10)
4
+ openfeature-go-feature-flag-provider (0.1.5)
5
+ faraday-net_http_persistent (~> 2.3)
6
6
  openfeature-sdk (~> 0.3.1)
7
7
 
8
8
  GEM
@@ -12,24 +12,30 @@ GEM
12
12
  public_suffix (>= 2.0.2, < 7.0)
13
13
  ast (2.4.2)
14
14
  bigdecimal (3.1.8)
15
+ connection_pool (2.5.3)
15
16
  crack (1.0.0)
16
17
  bigdecimal
17
18
  rexml
18
19
  diff-lcs (1.5.1)
19
20
  docile (1.4.1)
20
- faraday (2.12.1)
21
+ faraday (2.13.4)
21
22
  faraday-net_http (>= 2.0, < 3.5)
22
23
  json
23
24
  logger
24
- faraday-net_http (3.4.0)
25
+ faraday-net_http (3.4.1)
25
26
  net-http (>= 0.5.0)
27
+ faraday-net_http_persistent (2.3.1)
28
+ faraday (~> 2.5)
29
+ net-http-persistent (>= 4.0.4, < 5)
26
30
  hashdiff (1.1.1)
27
- json (2.7.2)
31
+ json (2.13.2)
28
32
  language_server-protocol (3.17.0.3)
29
33
  lint_roller (1.1.0)
30
- logger (1.6.1)
31
- net-http (0.5.0)
34
+ logger (1.7.0)
35
+ net-http (0.6.0)
32
36
  uri
37
+ net-http-persistent (4.0.6)
38
+ connection_pool (~> 2.2, >= 2.2.4)
33
39
  openfeature-sdk (0.3.1)
34
40
  parallel (1.24.0)
35
41
  parser (3.3.0.5)
@@ -92,7 +98,7 @@ GEM
92
98
  rubocop-performance (~> 1.20.2)
93
99
  strscan (3.1.0)
94
100
  unicode-display_width (2.5.0)
95
- uri (1.0.2)
101
+ uri (1.0.3)
96
102
  webmock (3.23.1)
97
103
  addressable (>= 2.8.0)
98
104
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -45,11 +45,11 @@ gem install openfeature-go-feature-flag-provider
45
45
 
46
46
  The `OpenFeature::GoFeatureFlag::Provider` needs some options to be created and then set in the OpenFeature SDK.
47
47
 
48
- | **Option** | **Description** |
49
- |------------|---------------------------------------------------------------------------------------------------------------------------------------------|
50
- | `endpoint` | **(mandatory)** The URL to access to the relay-proxy.<br />*(example: `https://relay.proxy.gofeatureflag.org/`)* |
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
-
48
+ | **Option** | **Description** |
49
+ |-------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
50
+ | `endpoint` | **(mandatory)** The URL to access to the relay-proxy.<br />*(example: `https://relay.proxy.gofeatureflag.org/`)* |
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
+ | `instrumentation` | [Faraday instrumentation](https://github.com/lostisland/faraday/blob/main/docs/middleware/included/instrumentation.md) hash |
53
53
  The only required option to create a `GoFeatureFlagProvider` is the URL _(`endpoint`)_ to your GO Feature Flag relay-proxy instance.
54
54
 
55
55
  ```ruby
@@ -10,7 +10,7 @@ module OpenFeature
10
10
  def initialize(options: Options.new)
11
11
  @metadata = SDK::Provider::ProviderMetadata.new(name: PROVIDER_NAME)
12
12
  @options = options
13
- @goff_api = GoFeatureFlagApi.new(options: options)
13
+ @goff_api = GoFeatureFlagApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers, instrumentation: options.instrumentation)
14
14
  end
15
15
 
16
16
  def fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil)
@@ -3,7 +3,7 @@
3
3
  require "open_feature/sdk"
4
4
  require "net/http"
5
5
  require "json"
6
- require "faraday"
6
+ require "faraday/net_http_persistent"
7
7
  require_relative "error/errors"
8
8
  require_relative "model/ofrep_api_response"
9
9
 
@@ -11,13 +11,13 @@ module OpenFeature
11
11
  module GoFeatureFlag
12
12
  # This class is the entry point for the GoFeatureFlagProvider
13
13
  class GoFeatureFlagApi
14
- attr_reader :options
15
- def initialize(options: {})
16
- @options = options
17
- @faraday_connection = Faraday.new(
18
- url: @options.endpoint,
19
- headers: {"Content-Type" => "application/json"}.merge(@options.custom_headers || {})
20
- )
14
+ def initialize(endpoint: nil, custom_headers: nil, instrumentation: nil)
15
+ @faraday_connection = Faraday.new(url: endpoint, headers: headers(custom_headers)) do |f|
16
+ f.request :instrumentation, instrumentation if instrumentation
17
+ f.adapter :net_http_persistent do |http|
18
+ http.idle_timeout = 30
19
+ end
20
+ end
21
21
  end
22
22
 
23
23
  def evaluate_ofrep_api(flag_key:, evaluation_context:)
@@ -57,6 +57,10 @@ module OpenFeature
57
57
 
58
58
  private
59
59
 
60
+ def headers(custom_headers)
61
+ {"Content-Type" => "application/json"}.merge(custom_headers || {})
62
+ end
63
+
60
64
  def parse_error_response(response)
61
65
  required_keys = %w[key error_code]
62
66
  parsed = JSON.parse(response.body)
@@ -6,13 +6,15 @@ 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
9
+ attr_accessor :endpoint, :custom_headers, :exporter_metadata, :instrumentation
10
10
 
11
- def initialize(endpoint: nil, headers: {}, exporter_metadata: {})
11
+ def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentation: nil)
12
12
  validate_endpoint(endpoint: endpoint)
13
+ validate_instrumentation(instrumentation: instrumentation)
13
14
  @endpoint = endpoint
14
15
  @custom_headers = headers
15
16
  @exporter_metadata = exporter_metadata
17
+ @instrumentation = instrumentation
16
18
  end
17
19
 
18
20
  private
@@ -25,6 +27,13 @@ module OpenFeature
25
27
  rescue URI::InvalidURIError
26
28
  raise ArgumentError, "Invalid URL for endpoint: #{endpoint}"
27
29
  end
30
+
31
+ def validate_instrumentation(instrumentation: nil)
32
+ return if instrumentation.nil?
33
+ return if instrumentation.is_a?(Hash)
34
+
35
+ raise ArgumentError, "Invalid type for instrumentation: #{instrumentation.class}"
36
+ end
28
37
  end
29
38
  end
30
39
  end
@@ -1,5 +1,5 @@
1
1
  module OpenFeature
2
2
  module GoFeatureFlag
3
- GO_FEATURE_FLAG_PROVIDER_VERSION = "0.1.3"
3
+ GO_FEATURE_FLAG_PROVIDER_VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_runtime_dependency "openfeature-sdk", "~> 0.3.1"
33
- spec.add_runtime_dependency "faraday", "~> 2.10"
33
+ spec.add_runtime_dependency "faraday-net_http_persistent", "~> 2.3"
34
34
 
35
35
  spec.add_development_dependency "rake", "~> 13.0"
36
36
  spec.add_development_dependency "rspec", "~> 3.12.0"
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.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Poignant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-27 00:00:00.000000000 Z
11
+ date: 2025-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openfeature-sdk
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.3.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: faraday
28
+ name: faraday-net_http_persistent
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.10'
33
+ version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.10'
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement