OpenFeature
An open standard for feature flags
Simple API
- TypeScript
- Java
- Go
- C#
- PHP
import {
OpenFeature
} from '@openfeature/js-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 (
"context"
"github.com/open-feature/go-sdk/pkg/openfeature"
)
client := openfeature.NewClient("my-client")
value, err := client.
BooleanValue(
context.Background(), "new-look", true,
openfeature.EvaluationContext{},
)
using OpenFeature;
var client = Api.Instance.GetClient("my-client");
var value = await client.GetBooleanValue("new-look", false);
use OpenFeature\OpenFeatureAPI;
$api = OpenFeatureAPI::getInstance();
$client = $api->getClient("my-client");
$value = $client->getBooleanValue('new-look', true);
Flexible integration
- TypeScript
- Java
- Go
- C#
- PHP
class MyFlagProvider implements Provider {
//...
resolveBooleanEvaluation(
flagKey: string,
defaultValue: boolean,
context: Context,
): Promise<ResolutionDetails<boolean>> {
// your implementation
}
//...
}
class MyFlagProvider implements Provider {
//...
@Override
public ProviderEvaluation<Boolean> getBooleanEvaluation(
String flagKey,
Boolean defaultValue,
EvaluationContext ctx) {
// your implementation
}
//...
}
type MyFlagProvider struct {}
//...
func (p MyFlagProvider) BooleanEvaluation(
flag string,
defaultValue bool,
evalCtx openfeature.EvaluationContext,
) BoolResolutionDetail {
// your implementation
}
//...
public class MyFlagProvider : FeatureProvider
{
//...
public Task<ResolutionDetails<bool>> ResolveBooleanValue(
string flagKey,
bool defaultValue,
EvaluationContext? context = null)
{
// your implementation
}
//...
}
class MyFlagProvider implements Provider
{
//...
public function resolveBooleanValue(
string $flagKey,
bool $defaultValue,
?EvaluationContext $context = null,
): ResolutionDetails
{
// your implementation
}
//...
}
Powerful extensions
- TypeScript
- Java
- Go
- C#
- PHP
class MyHook implements Hook {
before(
hookContext: BeforeHookContext,
hookHints?: HookHints) {
// do something before flag evaluation
}
after(
hookContext: Readonly<HookContext<FlagValue>>,
evaluationDetails: EvaluationDetails<FlagValue>,
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
}
//...
}
class MyHook implements Hook
{
//...
public function before(
HookContext $context,
HookHints $hints,
): ?EvaluationContext
{
// do something before flag evaluation
}
public function after(
HookContext $context,
ResolutionDetails $details,
HookHints $hints,
): void
{
// do something after flag evaluation
}
//...
}