Skip to content

Commit

Permalink
Merge branch 'main' into setup-release-process
Browse files Browse the repository at this point in the history
  • Loading branch information
maxveldink authored Apr 29, 2024
2 parents 8f66441 + d437e7f commit fddd62f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 0 additions & 2 deletions providers/openfeature-flagd-provider/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ source "https://rubygems.org"

# Specify your gem's dependencies in openfeature-flagd-provider.gemspec
gemspec

gem "openfeature-sdk"
4 changes: 2 additions & 2 deletions providers/openfeature-flagd-provider/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
openfeature-flagd-provider (0.0.1)
grpc (~> 1.50)
openfeature-sdk (~> 0.3)

GEM
remote: https://rubygems.org/
Expand All @@ -22,7 +23,7 @@ GEM
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
openfeature-sdk (0.3.0)
openfeature-sdk (0.3.1)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
Expand Down Expand Up @@ -82,7 +83,6 @@ PLATFORMS

DEPENDENCIES
openfeature-flagd-provider!
openfeature-sdk
rake (~> 13.0)
rspec (~> 3.12.0)
rubocop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Client
attr_reader :metadata

def initialize(configuration: nil)
@metadata = Metadata.new(PROVIDER_NAME)
@metadata = OpenFeature::SDK::Provider::ProviderMetadata.new(name: PROVIDER_NAME)
@grpc_client = grpc_client(configuration)
end

Expand Down Expand Up @@ -77,12 +77,16 @@ def fetch_object_value(flag_key:, default_value:, evaluation_context: nil)

private

Metadata = Struct.new("Metadata", :name)
ResolutionDetails = Struct.new("ResolutionDetails", :error_code, :error_message, :reason, :value, :variant)

def process_request(&block)
response = block.call
ResolutionDetails.new(nil, nil, response.reason, response.value, response.variant)
OpenFeature::SDK::Provider::ResolutionDetails.new(
value: response.value,
reason: response.reason,
variant: response.variant,
error_code: nil,
error_message: nil,
flag_metadata: nil
)
rescue GRPC::NotFound => e
error_response("FLAG_NOT_FOUND", e.message)
rescue GRPC::InvalidArgument => e
Expand All @@ -104,7 +108,14 @@ def prepare_evaluation_context(evaluation_context)
end

def error_response(error_code, error_message)
ResolutionDetails.new(error_code, error_message, "ERROR", nil, nil)
OpenFeature::SDK::Provider::ResolutionDetails.new(
value: nil,
reason: "ERROR",
variant: nil,
error_code: error_code,
error_message: error_message,
flag_metadata: nil
)
end

def grpc_client(configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_runtime_dependency "grpc", "~> 1.50"
spec.add_runtime_dependency "openfeature-sdk", "~> 0.3"

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.12.0"
Expand Down

0 comments on commit fddd62f

Please sign in to comment.