| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This provider allows for using LaunchDarkly with the OpenFeature SDK for Ruby.
This provider is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications.
Warning
This is a beta version. The API is not stabilized and may introduce breaking changes.
Note
This OpenFeature provider uses production versions of the LaunchDarkly SDK, which adhere to our standard versioning policy.
LaunchDarkly is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!
This version of the LaunchDarkly provider works with Ruby 3.4 and above.
This matrix mirrors the feature matrix of the OpenFeature SDK for Ruby and describes what this provider supports. Rows which are not supported state whether the limitation comes from the OpenFeature Ruby SDK or from the provider.
| Status | Feature | Notes |
|---|---|---|
| ✅ | Providers | Evaluates boolean, string, integer, float, number, and object flags through the LaunchDarkly Ruby SDK. |
| ✅ | Targeting | The EvaluationContext is converted to a LaunchDarkly single or multi-context. See OpenFeature Specific Considerations. |
| ✅ | Hooks | Hooks are registered on the OpenFeature API and client; the provider requires no additional support and its results are visible to hooks, including flag metadata. |
| ✅ | Logging | The provider logs through the logger of the LaunchDarkly::Config it is given. |
| ✅ | Domains | Domains bind clients to providers in the OpenFeature SDK; a separate provider instance may be registered per domain. |
| ✅ | Eventing | LaunchDarkly data source status changes are emitted as PROVIDER_READY, PROVIDER_STALE, and PROVIDER_ERROR. Flag changes are emitted as PROVIDER_CONFIGURATION_CHANGED with the changed flag key. |
| ✅ | Initialization | init reports whether the LaunchDarkly client became ready within the configured wait time; a failure results in the ERROR state so that cached or fallback flag data is still evaluated. |
| ✅ | Shutdown | shutdown closes the LaunchDarkly client. A closed client cannot be restarted, so a new provider instance is required afterward. |
| ✅ | Tracking | track sends a LaunchDarkly custom event for the evaluation context, with the tracking event value and remaining details attached. |
| ✅ | Transaction Context Propagation | Provided by the OpenFeature SDK, which merges the transaction context into the evaluation context before the provider is called; no provider support is required. |
| ✅ | Extending | This provider is itself an extension of the OpenFeature SDK. The underlying LaunchDarkly client is available through provider.client for functionality with no OpenFeature equivalent. |
| ✅ | Flag metadata | LaunchDarkly evaluation reason details are returned as OpenFeature flag metadata. See Flag Metadata. |
Supported: ✅ | Partially supported: ⚠️ | Not supported: ❌
Install the library
$ gem install launchdarkly-openfeature-server-sdkrequire 'open_feature/sdk'
require 'ldclient-rb'
require 'ldclient-openfeature'
provider = LaunchDarkly::OpenFeature::Provider.new(
'sdk-key',
LaunchDarkly::Config.new
)
OpenFeature::SDK.configure do |config|
config.set_provider(provider)
end
# Refer to OpenFeature documentation for getting a client and performing evaluations.Refer to the SDK reference guide for instructions on getting started with using the SDK.
For information on using the OpenFeature client please refer to the OpenFeature Documentation.
LaunchDarkly evaluates contexts, and it can either evaluate a single-context, or a multi-context. When using OpenFeature both single and multi-contexts must be encoded into a single EvaluationContext. This is accomplished by looking for an attribute named kind in the EvaluationContext.
There are 4 different scenarios related to the kind:
The kind attribute should be a string containing only contain ASCII letters, numbers, ., _ or -.
The OpenFeature specification allows for an optional targeting key, but LaunchDarkly requires a key for evaluation. A targeting key must be specified for each context being evaluated. It may be specified using either targeting_key, as it is in the OpenFeature specification, or key, which is the typical LaunchDarkly identifier for the targeting key. If a targeting_key and a key are specified, then the targeting_key will take precedence.
There are several other attributes which have special functionality within a single or multi-context.
context = EvaluationContext(key: "the-key")context = EvaluationContext(key: "org-key", kind: "organization")attributes = {
kind: "multi",
organization: {
name: "the-org-name",
key, "my-org-key",
myCustomAttribute, "myAttributeValue"
},
user: {
key: "my-user-key",
anonymous, true
}
}
context = EvaluationContext(**attributes)attributes = {
key: "org-key",
kind: "organization",
myCustomAttribute: "myAttributeValue",
privateAttributes: ["myCustomAttribute"]
}
context = EvaluationContext(**attributes)attributes = {
kind: "organization",
organization: {
name: "the-org-name",
key: "my-org-key",
# This will ONLY apply to the "organization" attributes.
privateAttributes: ["myCustomAttribute"],
# This attribute will be private.
myCustomAttribute: "myAttributeValue",
},
user: [
key: "my-user-key",
anonymous = > true,
# This attribute will not be private.
myCustomAttribute: "myAttributeValue",
]
}
context = EvaluationContext(**attributes)Evaluations include flag metadata for the LaunchDarkly specific parts of the evaluation result which have no OpenFeature equivalent. Each entry is absent when it does not apply to the evaluation.
| Key | Type | Description |
|---|---|---|
| variationIndex | integer | The index of the returned variation. Absent for default values. |
| inExperiment | boolean | Present, and true, when the evaluation was part of an experiment. |
| ruleIndex | integer | The index of the rule that matched. |
| ruleId | string | The identifier of the rule that matched. |
| prerequisiteKey | string | The key of the prerequisite flag that failed. |
| bigSegmentsStatus | string | The status of the Big Segments query made during the evaluation. |
details = client.fetch_boolean_details(flag_key: "my-flag", default_value: false)
in_experiment = details.flag_metadata.fetch("inExperiment", false)Check out our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.
The authoritative description of all properties and methods is in the ruby documentation.
We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.
| Back | FazBrowse Home | New Git URL |