Documentation ¶
Overview ¶
This package provides a Flipt OpenFeature Provider for interacting with the Flipt service backend using the OpenFeature Go SDK.
From the OpenFeature Specification: Providers are the "translator" between the flag evaluation calls made in application code, and the flag management system that stores flags and in some cases evaluates flags.
You can configure the provider to connect to Flipt using any of the provided "Option"s. This configuration allows you to specify the "[ServiceType]" (protocol), and to configure the host, port and other properties to connect to the Flipt service.
Example ¶
package main import ( "context" "github.com/open-feature/go-sdk/pkg/openfeature" "go.flipt.io/flipt-openfeature-provider/pkg/provider/flipt" ) func main() { openfeature.SetProvider(flipt.NewProvider( flipt.WithAddress("localhost:9000"), )) client := openfeature.NewClient("my-app") value, err := client.BooleanValue( context.Background(), "v2_enabled", false, openfeature.NewEvaluationContext("tim@apple.com", map[string]interface{}{ "favorite_color": "blue", }), ) if err != nil { panic(err) } if value { // do something } else { // do something else } }
Output:
Index ¶
- type Config
- type Option
- type Provider
- func (p Provider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, ...) of.BoolResolutionDetail
- func (p Provider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, ...) of.FloatResolutionDetail
- func (p Provider) Hooks() []of.Hook
- func (p Provider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, ...) of.IntResolutionDetail
- func (p Provider) Metadata() of.Metadata
- func (p Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue interface{}, ...) of.InterfaceResolutionDetail
- func (p Provider) StringEvaluation(ctx context.Context, flag string, defaultValue string, ...) of.StringResolutionDetail
- type Service
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Address string CertificatePath string TokenProvider sdk.ClientTokenProvider Namespace string }
Config is a configuration for the FliptProvider.
type Option ¶
type Option func(*Provider)
Option is a configuration option for the provider.
func ForNamespace ¶ added in v0.1.5
ForNamespace sets the namespace for flag lookup and evaluation in Flipt.
func WithAddress ¶ added in v0.1.2
WithAddress sets the address for the remote Flipt gRPC or HTTP API.
func WithCertificatePath ¶
WithCertificatePath is an Option to set the certificate path (grpc only).
func WithClientTokenProvider ¶ added in v0.1.5
func WithClientTokenProvider(tokenProvider sdk.ClientTokenProvider) Option
WithClientTokenProvider sets the token provider for auth to support client auth needs.
func WithConfig ¶
WithConfig is an Option to set the entire configuration.
func WithService ¶
WithService is an Option to set the service for the Provider.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the FeatureProvider interface and provides functions for evaluating flags with Flipt.
func NewProvider ¶
NewProvider returns a new Flipt provider.
func (Provider) BooleanEvaluation ¶
func (p Provider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, evalCtx of.FlattenedContext) of.BoolResolutionDetail
BooleanEvaluation returns a boolean flag.
func (Provider) FloatEvaluation ¶
func (p Provider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, evalCtx of.FlattenedContext) of.FloatResolutionDetail
FloatEvaluation returns a float flag.
func (Provider) IntEvaluation ¶
func (p Provider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, evalCtx of.FlattenedContext) of.IntResolutionDetail
IntEvaluation returns an int flag.
func (Provider) ObjectEvaluation ¶
func (p Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue interface{}, evalCtx of.FlattenedContext) of.InterfaceResolutionDetail
ObjectEvaluation returns an object flag with attachment if any. Value is a map of key/value pairs ([string]interface{}).
func (Provider) StringEvaluation ¶
func (p Provider) StringEvaluation(ctx context.Context, flag string, defaultValue string, evalCtx of.FlattenedContext) of.StringResolutionDetail
StringEvaluation returns a string flag.
type Service ¶ added in v0.1.2
type Service interface { GetFlag(ctx context.Context, namespaceKey, flagKey string) (*flipt.Flag, error) Evaluate(ctx context.Context, namespaceKey, flagKey string, evalCtx map[string]interface{}) (*evaluation.VariantEvaluationResponse, error) Boolean(ctx context.Context, namespaceKey, flagKey string, evalCtx map[string]interface{}) (*evaluation.BooleanEvaluationResponse, error) }