Skip to content

Commit

Permalink
feat!: update flagd name and grpc schema (#30)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Beemer <[email protected]>
  • Loading branch information
beeme1mr authored May 13, 2024
1 parent d4f8c98 commit ddd438a
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "providers/openfeature-flagd-provider/schemas"]
path = providers/openfeature-flagd-provider/schemas
url = https://github.com/open-feature/schemas
url = https://github.com/open-feature/flagd-schemas
9 changes: 9 additions & 0 deletions providers/openfeature-flagd-provider/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
inherit_from: ../../shared_config/.rubocop.yml

inherit_mode:
merge:
- Exclude

AllCops:
Exclude:
# gRPC generated files
- 'lib/openfeature/flagd/provider/flagd/**/*.rb'
12 changes: 6 additions & 6 deletions providers/openfeature-flagd-provider/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenFeature FlagD Provider for Ruby
# OpenFeature flagd Provider for Ruby

This is the Ruby [provider](https://openfeature.dev/docs/specification/sections/providers) implementation of the [FlagD](https://github.com/open-feature/flagd)
This is the Ruby [provider](https://openfeature.dev/docs/specification/sections/providers) implementation of the [flagd](https://flagd.dev/)

## Installation

Expand All @@ -24,7 +24,7 @@ gem install openfeature-flagd-provider

## Usage

The `OpenFeature::FlagD` supports multiple configuration options that dictate how the SDK communicates with flagd.
The `OpenFeature::Flagd` supports multiple configuration options that dictate how the SDK communicates with flagd.
Options can be defined in the constructor or as environment variables, with constructor options having the highest precedence.

### Available options
Expand All @@ -42,7 +42,7 @@ Options can be defined in the constructor or as environment variables, with cons
```ruby
OpenFeature::SDK.configure do |config|
# your provider of choice
config.provider = OpenFeature::FlagD::Provider.configure do |provider_config|
config.provider = OpenFeature::Flagd::Provider.configure do |provider_config|
provider_config.host = "localhost"
provider_config.port = 8013
provider_config.tls = false
Expand All @@ -55,7 +55,7 @@ end
```ruby
OpenFeature::SDK.configure do |config|
# your provider of choice
config.provider = OpenFeature::FlagD::Provider.configure do |provider_config|
config.provider = OpenFeature::Flagd::Provider.configure do |provider_config|
provider_config.unix_socket_path = "tmp/flagd.sock"
end
end
Expand All @@ -67,7 +67,7 @@ end
```ruby
OpenFeature::SDK.configure do |config|
# your provider of choice
config.provider = OpenFeature::FlagD::Provider.configure do |provider_config|
config.provider = OpenFeature::Flagd::Provider.configure do |provider_config|
provider_config.host = "localhost"
provider_config.port = 8013
provider_config.tls = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.7'

services:
flagd:
image: ghcr.io/open-feature/flagd:v0.9.2
image: ghcr.io/open-feature/flagd:v0.10.1
ports:
- '127.0.0.1:8013:8013'
volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
require_relative "provider/version"

module OpenFeature
module FlagD
# Provider represents the entry point for interacting with the FlagD provider
module Flagd
# Provider represents the entry point for interacting with the Flagd provider
# values. The implementation follows the details specified in https://openfeature.dev/docs/specification/sections/providers
#
# Provider contains functionality to configure the GRPC connection via
# flagd_client = OpenFeature::FlagD::Provider.get_client
# flagd_client = OpenFeature::Flagd::Provider.get_client
# flagd_client.configure do |config|
# config.host = 'localhost'
# config.port = 8379
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
require "grpc"
require "google/protobuf/well_known_types"

require_relative "schema/v1/schema_services_pb"
require_relative "flagd/evaluation/v1/evaluation_services_pb"
require_relative "configuration"

module OpenFeature
module FlagD
module Flagd
module Provider
# Client represents a wrapper for the GRPC stub that allows for resolution of boolean, string, number, and object
# values. The implementation follows the details specified in https://openfeature.dev/docs/specification/sections/providers
Expand Down Expand Up @@ -42,7 +42,7 @@ def initialize(configuration: nil)
end

def fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil)
request = Grpc::ResolveBooleanRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
request = Grpc::Evaluation::ResolveBooleanRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
process_request(default_value) { @grpc_client.resolve_boolean(request) }
end

Expand All @@ -56,22 +56,22 @@ def fetch_number_value(flag_key:, default_value:, evaluation_context: nil)
end

def fetch_integer_value(flag_key:, default_value:, evaluation_context: nil)
request = Grpc::ResolveIntRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
request = Grpc::Evaluation::ResolveIntRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
process_request(default_value) { @grpc_client.resolve_int(request) }
end

def fetch_float_value(flag_key:, default_value:, evaluation_context: nil)
request = Grpc::ResolveFloatRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
request = Grpc::Evaluation::ResolveFloatRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
process_request(default_value) { @grpc_client.resolve_float(request) }
end

def fetch_string_value(flag_key:, default_value:, evaluation_context: nil)
request = Grpc::ResolveStringRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
request = Grpc::Evaluation::ResolveStringRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
process_request(default_value) { @grpc_client.resolve_string(request) }
end

def fetch_object_value(flag_key:, default_value:, evaluation_context: nil)
request = Grpc::ResolveObjectRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
request = Grpc::Evaluation::ResolveObjectRequest.new(flag_key: flag_key, context: prepare_evaluation_context(evaluation_context))
process_request(default_value) { @grpc_client.resolve_object(request) }
end

Expand Down Expand Up @@ -126,7 +126,7 @@ def grpc_client(configuration)
)
end

Grpc::Service::Stub.new(server_address(configuration), options).freeze
Grpc::Evaluation::Service::Stub.new(server_address(configuration), options).freeze
end

def server_address(configuration)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

module OpenFeature
module FlagD
module Flagd
module Provider
# Represents the configuration object for the FlagD provider,
# Represents the configuration object for the Flagd provider,
# This class is not meant to be interacted with directly but instead through the
# <tt>OpenFeature::FlagD::Provider.configure</tt> method
# <tt>OpenFeature::Flagd::Provider.configure</tt> method
class Configuration < Struct.new(:host, :port, :tls, :unix_socket_path, :root_cert_path, keyword_init: true)
ENVIRONMENT_CONFIG_NAME = {
host: "FLAGD_HOST",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ddd438a

Please sign in to comment.