From c982476167ae5044f38283f97dad605eaebb4099 Mon Sep 17 00:00:00 2001 From: Aleksandras Maliuginas Date: Wed, 28 Jan 2026 09:34:37 +0200 Subject: [PATCH 1/2] feat: Extend http client to allow using native Faraday request timeout Signed-off-by: Aleksandras Maliuginas --- providers/openfeature-go-feature-flag-provider/README.md | 1 + .../lib/openfeature/go-feature-flag/client/http_api.rb | 5 +++-- .../openfeature/go-feature-flag/go_feature_flag_provider.rb | 2 +- .../lib/openfeature/go-feature-flag/options.rb | 5 +++-- .../spec/openfeature/gofeatureflag/options_spec.rb | 5 +++++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/providers/openfeature-go-feature-flag-provider/README.md b/providers/openfeature-go-feature-flag-provider/README.md index cbe33c5..1d556cb 100644 --- a/providers/openfeature-go-feature-flag-provider/README.md +++ b/providers/openfeature-go-feature-flag-provider/README.md @@ -50,6 +50,7 @@ The `OpenFeature::GoFeatureFlag::Provider` needs some options to be created and | `endpoint` | **(mandatory)** The URL to access to the relay-proxy.
*(example: `https://relay.proxy.gofeatureflag.org/`)* | | `headers` | A `Hash` object containing the headers to send to the relay-proxy.
*(example to send APIKey: `{"Authorization" => "Bearer my-api-key"}` | | `instrumentation` | [Faraday instrumentation](https://github.com/lostisland/faraday/blob/main/docs/middleware/included/instrumentation.md) hash | +| `timeout` | Request timeout in seconds ([Faraday request options](https://rubydoc.info/github/lostisland/faraday/Faraday/Connection)). | The only required option to create a `GoFeatureFlagProvider` is the URL _(`endpoint`)_ to your GO Feature Flag relay-proxy instance. ```ruby diff --git a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb index ef85cbb..a43acc4 100644 --- a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb +++ b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb @@ -7,9 +7,10 @@ module OpenFeature module GoFeatureFlag module Client class HttpApi < Common - def initialize(endpoint: nil, custom_headers: nil, instrumentation: nil) + def initialize(endpoint: nil, custom_headers: nil, instrumentation: nil, timeout: nil) @custom_headers = custom_headers - @faraday_connection = Faraday.new(url: endpoint, headers: headers) do |f| + request_options = {timeout: timeout, open_timeout: 30} + @faraday_connection = Faraday.new(url: endpoint, headers: headers, request: request_options) do |f| f.request :instrumentation, instrumentation if instrumentation f.adapter :net_http_persistent do |http| http.idle_timeout = 30 diff --git a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/go_feature_flag_provider.rb b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/go_feature_flag_provider.rb index a091dca..b660a25 100644 --- a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/go_feature_flag_provider.rb +++ b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/go_feature_flag_provider.rb @@ -103,7 +103,7 @@ def validate_parameters(flag_key, evaluation_context) def build_client(options) case options.type when "http" - Client::HttpApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers, instrumentation: options.instrumentation) + Client::HttpApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers, instrumentation: options.instrumentation, timeout: options.timeout) when "unix" Client::UnixApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers) else diff --git a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb index 5a32735..6bab6f3 100644 --- a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb +++ b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb @@ -6,9 +6,9 @@ module OpenFeature module GoFeatureFlag # This class is the configuration class for the GoFeatureFlagProvider class Options - attr_accessor :endpoint, :custom_headers, :exporter_metadata, :instrumentation, :type + attr_accessor :endpoint, :custom_headers, :exporter_metadata, :instrumentation, :type, :timeout - def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentation: nil, type: "http") + def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentation: nil, type: "http", timeout: 1) validate_endpoint(endpoint, type) validate_instrumentation(instrumentation: instrumentation) @type = type @@ -16,6 +16,7 @@ def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentatio @custom_headers = headers @exporter_metadata = exporter_metadata @instrumentation = instrumentation + @timeout = timeout end private diff --git a/providers/openfeature-go-feature-flag-provider/spec/openfeature/gofeatureflag/options_spec.rb b/providers/openfeature-go-feature-flag-provider/spec/openfeature/gofeatureflag/options_spec.rb index 3fac4ef..b54c8dd 100644 --- a/providers/openfeature-go-feature-flag-provider/spec/openfeature/gofeatureflag/options_spec.rb +++ b/providers/openfeature-go-feature-flag-provider/spec/openfeature/gofeatureflag/options_spec.rb @@ -23,5 +23,10 @@ it "should raise if instrumentation is not hash" do expect { OpenFeature::GoFeatureFlag::Options.new(instrumentation: "custom_name") }.to raise_error(ArgumentError, "Invalid type for instrumentation: String") end + + it "should allow custom timeout" do + options = OpenFeature::GoFeatureFlag::Options.new(endpoint: "http://localhost:1031", timeout: 5) + expect(options.timeout).to eq(5) + end end end From 93a492db09516d913cfe4e7dbff4bba33c789edb Mon Sep 17 00:00:00 2001 From: Aleksandras Maliuginas Date: Wed, 28 Jan 2026 09:45:10 +0200 Subject: [PATCH 2/2] fix: removed default option for timeout, to be handled by Faraday client Signed-off-by: Aleksandras Maliuginas --- .../lib/openfeature/go-feature-flag/client/http_api.rb | 2 +- .../lib/openfeature/go-feature-flag/options.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb index a43acc4..8364022 100644 --- a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb +++ b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/client/http_api.rb @@ -9,7 +9,7 @@ module Client class HttpApi < Common def initialize(endpoint: nil, custom_headers: nil, instrumentation: nil, timeout: nil) @custom_headers = custom_headers - request_options = {timeout: timeout, open_timeout: 30} + request_options = {timeout: timeout} @faraday_connection = Faraday.new(url: endpoint, headers: headers, request: request_options) do |f| f.request :instrumentation, instrumentation if instrumentation f.adapter :net_http_persistent do |http| diff --git a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb index 6bab6f3..00e5502 100644 --- a/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb +++ b/providers/openfeature-go-feature-flag-provider/lib/openfeature/go-feature-flag/options.rb @@ -8,7 +8,7 @@ module GoFeatureFlag class Options attr_accessor :endpoint, :custom_headers, :exporter_metadata, :instrumentation, :type, :timeout - def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentation: nil, type: "http", timeout: 1) + def initialize(endpoint: nil, headers: {}, exporter_metadata: {}, instrumentation: nil, type: "http", timeout: nil) validate_endpoint(endpoint, type) validate_instrumentation(instrumentation: instrumentation) @type = type