Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openfeature-go-feature-flag-provider

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openfeature-go-feature-flag-provider

  • 0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

go-feature-flag logo

GO Feature Flag - OpenFeature Ruby provider

gem Documentation Issues Join us on slack

This repository contains the official Ruby OpenFeature provider for accessing your feature flags with GO Feature Flag.

In conjunction with the OpenFeature SDK you will be able to evaluate your feature flags in your Ruby applications.

For documentation related to flags management in GO Feature Flag, refer to the GO Feature Flag documentation website.

Functionalities:

  • Manage the integration of the OpenFeature Ruby SDK and GO Feature Flag relay-proxy.

Dependency Setup

Gem Package Manager

Add this line to your application's Gemfile:

gem 'openfeature-go-feature-flag-provider'

And then execute:

bundle install

Or install it yourself as:

gem install openfeature-go-feature-flag-provider

Getting started

Initialize the provider

The OpenFeature::GoFeatureFlag::Provider needs some options to be created and then set in the OpenFeature SDK.

OptionDescription
endpoint(mandatory) The URL to access to the relay-proxy.
(example: https://relay.proxy.gofeatureflag.org/)
headersA Hash object containing the headers to send to the relay-proxy.
*(example to send APIKey: {"Authorization" => "Bearer my-api-key"}

The only required option to create a GoFeatureFlagProvider is the URL (endpoint) to your GO Feature Flag relay-proxy instance.

options = OpenFeature::GoFeatureFlag::Options.new(endpoint: "http://localhost:1031")
provider = OpenFeature::GoFeatureFlag::Provider.new(options:)

evaluation_context = OpenFeature::SDK::EvaluationContext.new(targeting_key: "9b9450f8-ab5c-4dcf-872f-feda3f6ccb16")

OpenFeature::SDK.configure do |config|
   config.set_provider(provider)
end
client = OpenFeature::SDK.build_client

bool_value = client.fetch_boolean_value(
  flag_key: "my-boolean-flag",
  default_value: false,
  evaluation_context:
)

if bool_value 
  puts "The flag is enabled"
else
  puts "The flag is disabled"
end

The evaluation context is the way for the client to specify contextual data that GO Feature Flag uses to evaluate the feature flags, it allows to define rules on the flag.

The targeting_key is mandatory for GO Feature Flag to evaluate the feature flag, it could be the id of a user, a session ID or anything you find relevant to use as identifier during the evaluation.

Evaluate a feature flag

The client is used to retrieve values for the current EvaluationContext. For example, retrieving a boolean value for the flag "my-flag":

client = OpenFeature::SDK.build_client

bool_value = client.fetch_boolean_value(
  flag_key: "my-boolean-flag",
  default_value: false,
  evaluation_context: evaluation_context
)

GO Feature Flag supports different all OpenFeature supported types of feature flags, it means that you can use all the accessor directly

# Bool
client.fetch_boolean_value(flag_key: 'my-flag', default_value: false, evaluation_context:)

# String
client.fetch_string_value(flag_key: 'my-flag', default_value: "default", evaluation_context:)

# Number
client.fetch_number_value(flag_key: 'my-flag', default_value: 0, evaluation_context:)

# Object
client.fetch_object_value(flag_key: 'my-flag', default_value: {"default" => true}, evaluation_context:)

Features status

StatusFeatureDescription
Flag evaluationIt is possible to evaluate all the type of flags
CachingMechanism is in place to refresh the cache in case of configuration change
Event StreamingNot supported by the SDK
LoggingNot supported by the SDK
Flag MetadataYou can retrieve your flag metadata directly in the evaluation details.

Implemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌

Contributing

This project welcomes contributions from the community. If you're interested in contributing, see the contributors' guide for some helpful tips.

FAQs

Package last updated on 02 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc