Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
/test/version_tmp/
/tmp/

#rspec
**/spec/examples.txt

# Used by dotenv library to load environment variables.
# .env

Expand Down Expand Up @@ -58,4 +61,4 @@ build-iPhoneSimulator/
.DS_Store

# Ignore jetbrains files
.idea/
.idea/
20 changes: 13 additions & 7 deletions providers/openfeature-go-feature-flag-provider/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
openfeature-go-feature-flag-provider (0.1.3)
faraday (~> 2.10)
faraday-net_http_persistent (~> 2.3)
openfeature-sdk (~> 0.3.1)

GEM
Expand All @@ -12,24 +12,30 @@ GEM
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
bigdecimal (3.1.8)
connection_pool (2.5.3)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.1)
docile (1.4.1)
faraday (2.12.1)
faraday (2.13.4)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-net_http (3.4.0)
faraday-net_http (3.4.1)
net-http (>= 0.5.0)
faraday-net_http_persistent (2.3.1)
faraday (~> 2.5)
net-http-persistent (>= 4.0.4, < 5)
hashdiff (1.1.1)
json (2.7.2)
json (2.13.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
logger (1.6.1)
net-http (0.5.0)
logger (1.7.0)
net-http (0.6.0)
uri
net-http-persistent (4.0.6)
connection_pool (~> 2.2, >= 2.2.4)
openfeature-sdk (0.3.1)
parallel (1.24.0)
parser (3.3.0.5)
Expand Down Expand Up @@ -92,7 +98,7 @@ GEM
rubocop-performance (~> 1.20.2)
strscan (3.1.0)
unicode-display_width (2.5.0)
uri (1.0.2)
uri (1.0.3)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Provider
def initialize(options: Options.new)
@metadata = SDK::Provider::ProviderMetadata.new(name: PROVIDER_NAME)
@options = options
@goff_api = GoFeatureFlagApi.new(options: options)
@goff_api = GoFeatureFlagApi.new(endpoint: options.endpoint, custom_headers: options.custom_headers)
end

def fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
require "open_feature/sdk"
require "net/http"
require "json"
require "faraday"
require "faraday/net_http_persistent"
require_relative "error/errors"
require_relative "model/ofrep_api_response"

module OpenFeature
module GoFeatureFlag
# This class is the entry point for the GoFeatureFlagProvider
class GoFeatureFlagApi
attr_reader :options
def initialize(options: {})
@options = options
@faraday_connection = Faraday.new(
url: @options.endpoint,
headers: {"Content-Type" => "application/json"}.merge(@options.custom_headers || {})
)
def initialize(endpoint: nil, custom_headers: nil)
@faraday_connection = Faraday.new(url: endpoint, headers: headers(custom_headers)) do |f|
f.adapter :net_http_persistent do |http|
http.idle_timeout = 30
end
end
end

def evaluate_ofrep_api(flag_key:, evaluation_context:)
Expand Down Expand Up @@ -57,6 +56,10 @@ def evaluate_ofrep_api(flag_key:, evaluation_context:)

private

def headers(custom_headers)
{"Content-Type" => "application/json"}.merge(custom_headers || {})
end

def parse_error_response(response)
required_keys = %w[key error_code]
parsed = JSON.parse(response.body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_runtime_dependency "openfeature-sdk", "~> 0.3.1"
spec.add_runtime_dependency "faraday", "~> 2.10"
spec.add_runtime_dependency "faraday-net_http_persistent", "~> 2.3"

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.12.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

RSpec.describe OpenFeature::GoFeatureFlag::GoFeatureFlagApi do
subject(:goff_api) do
options = OpenFeature::GoFeatureFlag::Options.new(endpoint: "http://localhost:1031")
described_class.new(options: options)
described_class.new(endpoint: "http://localhost:1031")
end

let(:default_evaluation_context) do
Expand Down