OpenFeature
An open standard for feature flags
Simple API
- TypeScript
- Java
- Go
- C#
import {
openFeature
} from '@openfeature/nodejs-sdk'
const client = openfeature.getClient('my-client');
const value = client
.getBooleanValue('new-look', false);
import dev.openfeature.javasdk.OpenFeatureAPI;
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
Client client = api.getClient();
Boolean value = client
.getBooleanValue("new-look", false);
import (
"github.com/open-feature/golang-sdk/pkg/openfeature"
)
client := openfeature.NewClient("my-client")
value, err := client.
BooleanValue(
"new-look", true,
openfeature.EvaluationContext{},
openfeature.EvaluationOptions{},
)
using OpenFeature.SDK;
var client = OpenFeature.Instance.GetClient("my-client");
var value = await client.GetBooleanValue("new-look", false);
Flexible integration
- TypeScript
- Java
- Go
- C#
class MyFlagProvider implements Provider {
//...
resolveBooleanEvaluation(
flagKey: string,
defaultValue: boolean,
context: Context,
options: FlagEvaluationOptions | undefined
): Promise<ResolutionDetails<boolean>> {
// your implementation
}
//...
}
class MyFlagProvider implements Provider {
//...
@Override
public ProviderEvaluation<Boolean> getBooleanEvaluation(
String flagKey,
Boolean defaultValue,
EvaluationContext ctx,
FlagEvaluationOptions options) {
// your implementation
}
//...
}
type MyFlagProvider struct {}
//...
func (p MyFlagProvider) BooleanEvaluation(
flag string,
defaultValue bool,
evalCtx openfeature.EvaluationContext,
options openfeature.EvaluationOptions,
) BoolResolutionDetail {
// your implementation
}
//...
public class MyFlagProvider : FeatureProvider
{
//...
public Task<ResolutionDetails<bool>> ResolveBooleanValue(
string flagKey,
bool defaultValue,
EvaluationContext? context = null,
FlagEvaluationOptions? config = null)
{
// your implementation
}
//...
}
Powerful extensions
- TypeScript
- Java
- Go
- C#
class MyHook implements Hook {
before(
hookContext: BeforeHookContext,
hookHints?: HookHints) {
// do something before flag evaluation
}
after(
hookContext: Readonly<HookContext<boolean>>,
evaluationDetails: EvaluationDetails<boolean>,
hookHints?: HookHints
) {
// do something after flag evaluation
}
}
class MyHook implements Hook {
Optional<EvaluationContext> before(
HookContext<T> ctx,
Map<String, Object>
hints) {
// do something before flag evaluation
}
void after(
HookContext<T> ctx,
FlagEvaluationDetails<T> details,
Map<String,
Object> hints) {
// do something after flag evaluation
}
}
type MyHook struct {}
//...
func (h MyHook) Before(
ctx openfeature.HookContext,
hints openfeature.HookHints,
) (*EvaluationContext, error) {
// do something before flag evaluation
}
func (h MyHook) After(
ctx openfeature.HookContext,
details openfeature.EvaluationDetails,
hints openfeature.HookHints,
) error {
// do something after flag evaluation
}
//...
public class MyHook : Hook
{
//...
public override Task<EvaluationContext> Before<T>(
HookContext<T> context,
IReadOnlyDictionary<string, object> hints = null)
{
// do something before flag evaluation
}
public override Task After<T>(
HookContext<T> context,
FlagEvaluationDetails<T> details,
IReadOnlyDictionary<string, object> hints = null)
{
// do something after flag evaluation
}
//...
}