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 dceaed8..02c8153 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}
+ @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..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
@@ -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: nil)
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