Documentation
¶
Overview ¶
Package openfeature provides global access to the OpenFeature API.
Index ¶
- Constants
- func AddHooks(hooks ...Hook)
- func SetEvaluationContext(evalCtx EvaluationContext)
- func SetLogger(l logr.Logger)
- func SetProvider(provider FeatureProvider)
- type BoolResolutionDetail
- type BooleanEvaluationDetails
- type Client
- func (c *Client) AddHooks(hooks ...Hook)
- func (c Client) BooleanValue(ctx context.Context, flag string, defaultValue bool, evalCtx EvaluationContext, ...) (bool, error)
- func (c Client) BooleanValueDetails(ctx context.Context, flag string, defaultValue bool, evalCtx EvaluationContext, ...) (BooleanEvaluationDetails, error)
- func (c *Client) EvaluationContext() EvaluationContext
- func (c Client) FloatValue(ctx context.Context, flag string, defaultValue float64, ...) (float64, error)
- func (c Client) FloatValueDetails(ctx context.Context, flag string, defaultValue float64, ...) (FloatEvaluationDetails, error)
- func (c Client) IntValue(ctx context.Context, flag string, defaultValue int64, ...) (int64, error)
- func (c Client) IntValueDetails(ctx context.Context, flag string, defaultValue int64, ...) (IntEvaluationDetails, error)
- func (c Client) Metadata() ClientMetadata
- func (c Client) ObjectValue(ctx context.Context, flag string, defaultValue interface{}, ...) (interface{}, error)
- func (c Client) ObjectValueDetails(ctx context.Context, flag string, defaultValue interface{}, ...) (InterfaceEvaluationDetails, error)
- func (c *Client) SetEvaluationContext(evalCtx EvaluationContext)
- func (c Client) StringValue(ctx context.Context, flag string, defaultValue string, ...) (string, error)
- func (c Client) StringValueDetails(ctx context.Context, flag string, defaultValue string, ...) (StringEvaluationDetails, error)
- func (c *Client) WithLogger(l logr.Logger) *Client
- type ClientMetadata
- type ErrorCode
- type EvaluationContext
- type EvaluationDetails
- type EvaluationOptions
- type FeatureProvider
- type FlattenedContext
- type FloatEvaluationDetails
- type FloatResolutionDetail
- type Hook
- type HookContext
- type HookHints
- type IClient
- type IntEvaluationDetails
- type IntResolutionDetail
- type InterfaceEvaluationDetails
- type InterfaceResolutionDetail
- type Metadata
- type NoopProvider
- func (e NoopProvider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, evalCtx FlattenedContext) BoolResolutionDetail
- func (e NoopProvider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, ...) FloatResolutionDetail
- func (e NoopProvider) Hooks() []Hook
- func (e NoopProvider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, evalCtx FlattenedContext) IntResolutionDetail
- func (e NoopProvider) Metadata() Metadata
- func (e NoopProvider) ObjectEvaluation(ctx context.Context, flag string, defaultValue interface{}, ...) InterfaceResolutionDetail
- func (e NoopProvider) StringEvaluation(ctx context.Context, flag string, defaultValue string, ...) StringResolutionDetail
- type Option
- type ProviderResolutionDetail
- type Reason
- type ResolutionDetail
- type ResolutionError
- func NewFlagNotFoundResolutionError(msg string) ResolutionError
- func NewGeneralResolutionError(msg string) ResolutionError
- func NewInvalidContextResolutionError(msg string) ResolutionError
- func NewParseErrorResolutionError(msg string) ResolutionError
- func NewProviderNotReadyResolutionError(msg string) ResolutionError
- func NewTargetingKeyMissingResolutionError(msg string) ResolutionError
- func NewTypeMismatchResolutionError(msg string) ResolutionError
- type StringEvaluationDetails
- type StringResolutionDetail
- type Type
- type UnimplementedHook
- func (u UnimplementedHook) After(hookContext HookContext, flagEvaluationDetails InterfaceEvaluationDetails, ...) error
- func (u UnimplementedHook) Before(hookContext HookContext, hookHints HookHints) (*EvaluationContext, error)
- func (u UnimplementedHook) Error(hookContext HookContext, err error, hookHints HookHints)
- func (u UnimplementedHook) Finally(hookContext HookContext, hookHints HookHints)
Examples ¶
Constants ¶
const ( // DefaultReason - the resolved value was configured statically, or otherwise fell back to a pre-configured value. DefaultReason Reason = "DEFAULT" // TargetingMatchReason - the resolved value was the result of a dynamic evaluation, such as a rule or specific user-targeting. TargetingMatchReason Reason = "TARGETING_MATCH" // SplitReason - the resolved value was the result of pseudorandom assignment. SplitReason Reason = "SPLIT" // DisabledReason - the resolved value was the result of the flag being disabled in the management system. DisabledReason Reason = "DISABLED" // UnknownReason - the reason for the resolved value could not be determined. UnknownReason Reason = "UNKNOWN" // ErrorReason - the resolved value was the result of an error. ErrorReason Reason = "ERROR" TargetingKey string = "targetingKey" // evaluation context map key. The targeting key uniquely identifies the subject (end-user, or client service) of a flag evaluation. )
Variables ¶
This section is empty.
Functions ¶
func AddHooks ¶
func AddHooks(hooks ...Hook)
AddHooks appends to the collection of any previously added hooks
func SetEvaluationContext ¶
func SetEvaluationContext(evalCtx EvaluationContext)
SetEvaluationContext sets the global evaluation context.
Types ¶
type BoolResolutionDetail ¶
type BoolResolutionDetail struct {
Value bool
ProviderResolutionDetail
}
BoolResolutionDetail provides a resolution detail with boolean type
type BooleanEvaluationDetails ¶ added in v0.5.0
type BooleanEvaluationDetails struct {
Value bool
EvaluationDetails
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the behaviour required of an openfeature client
func NewClient ¶
NewClient returns a new Client. Name is a unique identifier for this client
Example ¶
package main
import (
"fmt"
"github.com/open-feature/go-sdk/pkg/openfeature"
)
func main() {
client := openfeature.NewClient("example-client")
fmt.Printf("Client Name: %s", client.Metadata().Name())
}
Output: Client Name: example-client
func (Client) BooleanValue ¶
func (c Client) BooleanValue(ctx context.Context, flag string, defaultValue bool, evalCtx EvaluationContext, options ...Option) (bool, error)
BooleanValue performs a flag evaluation that returns a boolean.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/open-feature/go-sdk/pkg/openfeature"
)
func main() {
client := openfeature.NewClient("example-client")
value, err := client.BooleanValue(
context.Background(), "test-flag", true, openfeature.EvaluationContext{},
)
if err != nil {
log.Fatal("error while getting boolean value : ", err)
}
fmt.Printf("test-flag value: %v", value)
}
Output: test-flag value: true
func (Client) BooleanValueDetails ¶
func (c Client) BooleanValueDetails(ctx context.Context, flag string, defaultValue bool, evalCtx EvaluationContext, options ...Option) (BooleanEvaluationDetails, error)
BooleanValueDetails performs a flag evaluation that returns an evaluation details struct.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
func (*Client) EvaluationContext ¶
func (c *Client) EvaluationContext() EvaluationContext
EvaluationContext returns the client's evaluation context
func (Client) FloatValue ¶
func (c Client) FloatValue(ctx context.Context, flag string, defaultValue float64, evalCtx EvaluationContext, options ...Option) (float64, error)
FloatValue performs a flag evaluation that returns a float64.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/open-feature/go-sdk/pkg/openfeature"
)
func main() {
client := openfeature.NewClient("example-client")
value, err := client.FloatValue(
context.Background(), "test-flag", 0.55, openfeature.EvaluationContext{},
)
if err != nil {
log.Fatalf("error while getting float value: %v", err)
}
fmt.Printf("test-flag value: %v", value)
}
Output: test-flag value: 0.55
func (Client) FloatValueDetails ¶
func (c Client) FloatValueDetails(ctx context.Context, flag string, defaultValue float64, evalCtx EvaluationContext, options ...Option) (FloatEvaluationDetails, error)
FloatValueDetails performs a flag evaluation that returns an evaluation details struct.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
func (Client) IntValue ¶
func (c Client) IntValue(ctx context.Context, flag string, defaultValue int64, evalCtx EvaluationContext, options ...Option) (int64, error)
IntValue performs a flag evaluation that returns an int64.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/open-feature/go-sdk/pkg/openfeature"
)
func main() {
client := openfeature.NewClient("example-client")
value, err := client.IntValue(
context.Background(), "test-flag", 3, openfeature.EvaluationContext{},
)
if err != nil {
log.Fatalf("error while getting int value: %v", err)
}
fmt.Printf("test-flag value: %v", value)
}
Output: test-flag value: 3
func (Client) IntValueDetails ¶
func (c Client) IntValueDetails(ctx context.Context, flag string, defaultValue int64, evalCtx EvaluationContext, options ...Option) (IntEvaluationDetails, error)
IntValueDetails performs a flag evaluation that returns an evaluation details struct.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
func (Client) Metadata ¶
func (c Client) Metadata() ClientMetadata
Metadata returns the client's metadata
func (Client) ObjectValue ¶
func (c Client) ObjectValue(ctx context.Context, flag string, defaultValue interface{}, evalCtx EvaluationContext, options ...Option) (interface{}, error)
ObjectValue performs a flag evaluation that returns an object.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
Example ¶
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/open-feature/go-sdk/pkg/openfeature"
)
func main() {
client := openfeature.NewClient("example-client")
value, err := client.ObjectValue(
context.Background(), "test-flag", map[string]string{"foo": "bar"}, openfeature.EvaluationContext{},
)
if err != nil {
log.Fatal("error while getting object value : ", err)
}
str, _ := json.Marshal(value)
fmt.Printf("test-flag value: %v", string(str))
}
Output: test-flag value: {"foo":"bar"}
func (Client) ObjectValueDetails ¶
func (c Client) ObjectValueDetails(ctx context.Context, flag string, defaultValue interface{}, evalCtx EvaluationContext, options ...Option) (InterfaceEvaluationDetails, error)
ObjectValueDetails performs a flag evaluation that returns an evaluation details struct.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
func (*Client) SetEvaluationContext ¶
func (c *Client) SetEvaluationContext(evalCtx EvaluationContext)
SetEvaluationContext sets the client's evaluation context
func (Client) StringValue ¶
func (c Client) StringValue(ctx context.Context, flag string, defaultValue string, evalCtx EvaluationContext, options ...Option) (string, error)
StringValue performs a flag evaluation that returns a string.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/open-feature/go-sdk/pkg/openfeature"
)
func main() {
client := openfeature.NewClient("example-client")
value, err := client.StringValue(
context.Background(), "test-flag", "openfeature", openfeature.EvaluationContext{},
)
if err != nil {
log.Fatal("error while getting string value : ", err)
}
fmt.Printf("test-flag value: %v", value)
}
Output: test-flag value: openfeature
func (Client) StringValueDetails ¶
func (c Client) StringValueDetails(ctx context.Context, flag string, defaultValue string, evalCtx EvaluationContext, options ...Option) (StringEvaluationDetails, error)
StringValueDetails performs a flag evaluation that returns an evaluation details struct.
Parameters: - ctx is the standard go context struct used to manage requests (e.g. timeouts) - flag is the key that uniquely identifies a particular flag - defaultValue is returned if an error occurs - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx) - options are optional additional evaluation options e.g. WithHooks & WithHookHints
type ClientMetadata ¶
type ClientMetadata struct {
// contains filtered or unexported fields
}
ClientMetadata provides a client's metadata
type ErrorCode ¶ added in v0.5.0
type ErrorCode string
const ( // ProviderNotReadyCode - the value was resolved before the provider was ready. ProviderNotReadyCode ErrorCode = "PROVIDER_NOT_READY" // FlagNotFoundCode - the flag could not be found. FlagNotFoundCode ErrorCode = "FLAG_NOT_FOUND" // ParseErrorCode - an error was encountered parsing data, such as a flag configuration. ParseErrorCode ErrorCode = "PARSE_ERROR" // TypeMismatchCode - the type of the flag value does not match the expected type. TypeMismatchCode ErrorCode = "TYPE_MISMATCH" // TargetingKeyMissingCode - the provider requires a targeting key and one was not provided in the evaluation context. TargetingKeyMissingCode ErrorCode = "TARGETING_KEY_MISSING" // InvalidContextCode - the evaluation context does not meet provider requirements. InvalidContextCode ErrorCode = "INVALID_CONTEXT" // GeneralCode - the error was for a reason not enumerated above. GeneralCode ErrorCode = "GENERAL" )
type EvaluationContext ¶
type EvaluationContext struct {
TargetingKey string `json:"targetingKey"` // uniquely identifying the subject (end-user, or client service) of a flag evaluation
Attributes map[string]interface{} `json:"attributes"`
}
EvaluationContext https://github.com/open-feature/spec/blob/main/specification/evaluation-context/evaluation-context.md
type EvaluationDetails ¶
type EvaluationDetails struct {
FlagKey string
FlagType Type
ResolutionDetail
}
type EvaluationOptions ¶
type EvaluationOptions struct {
// contains filtered or unexported fields
}
EvaluationOptions should contain a list of hooks to be executed for a flag evaluation
func (EvaluationOptions) HookHints ¶
func (e EvaluationOptions) HookHints() HookHints
HookHints returns evaluation options' hook hints
func (EvaluationOptions) Hooks ¶
func (e EvaluationOptions) Hooks() []Hook
Hooks returns evaluation options' hooks
type FeatureProvider ¶
type FeatureProvider interface {
Metadata() Metadata
BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, evalCtx FlattenedContext) BoolResolutionDetail
StringEvaluation(ctx context.Context, flag string, defaultValue string, evalCtx FlattenedContext) StringResolutionDetail
FloatEvaluation(ctx context.Context, flag string, defaultValue float64, evalCtx FlattenedContext) FloatResolutionDetail
IntEvaluation(ctx context.Context, flag string, defaultValue int64, evalCtx FlattenedContext) IntResolutionDetail
ObjectEvaluation(ctx context.Context, flag string, defaultValue interface{}, evalCtx FlattenedContext) InterfaceResolutionDetail
Hooks() []Hook
}
FeatureProvider interface defines a set of functions that can be called in order to evaluate a flag. vendors should implement
type FlattenedContext ¶ added in v0.5.0
type FlattenedContext map[string]interface{}
FlattenedContext contains metadata for a given flag evaluation in a flattened structure. TargetingKey ("targetingKey") is stored as a string value if provided in the evaluation context.
type FloatEvaluationDetails ¶ added in v0.5.0
type FloatEvaluationDetails struct {
Value float64
EvaluationDetails
}
type FloatResolutionDetail ¶
type FloatResolutionDetail struct {
Value float64
ProviderResolutionDetail
}
FloatResolutionDetail provides a resolution detail with float64 type
type Hook ¶
type Hook interface {
Before(hookContext HookContext, hookHints HookHints) (*EvaluationContext, error)
After(hookContext HookContext, flagEvaluationDetails InterfaceEvaluationDetails, hookHints HookHints) error
Error(hookContext HookContext, err error, hookHints HookHints)
Finally(hookContext HookContext, hookHints HookHints)
}
Hook allows application developers to add arbitrary behavior to the flag evaluation lifecycle. They operate similarly to middleware in many web frameworks. https://github.com/open-feature/spec/blob/main/specification/hooks.md
type HookContext ¶
type HookContext struct {
// contains filtered or unexported fields
}
HookContext defines the base level fields of a hook context
func (HookContext) ClientMetadata ¶
func (h HookContext) ClientMetadata() ClientMetadata
ClientMetadata returns the client's metadata
func (HookContext) DefaultValue ¶
func (h HookContext) DefaultValue() interface{}
DefaultValue returns the hook context's default value
func (HookContext) EvaluationContext ¶
func (h HookContext) EvaluationContext() EvaluationContext
EvaluationContext returns the hook context's EvaluationContext
func (HookContext) FlagKey ¶
func (h HookContext) FlagKey() string
FlagKey returns the hook context's flag key
func (HookContext) FlagType ¶
func (h HookContext) FlagType() Type
FlagType returns the hook context's flag type
func (HookContext) ProviderMetadata ¶
func (h HookContext) ProviderMetadata() Metadata
ProviderMetadata returns the provider's metadata
type HookHints ¶
type HookHints struct {
// contains filtered or unexported fields
}
HookHints contains a map of hints for hooks
func NewHookHints ¶
NewHookHints constructs HookHints
type IClient ¶
type IClient interface {
Metadata() ClientMetadata
AddHooks(hooks ...Hook)
SetEvaluationContext(evalCtx EvaluationContext)
EvaluationContext() EvaluationContext
BooleanValue(ctx context.Context, flag string, defaultValue bool, evalCtx EvaluationContext, options ...Option) (bool, error)
StringValue(ctx context.Context, flag string, defaultValue string, evalCtx EvaluationContext, options ...Option) (string, error)
FloatValue(ctx context.Context, flag string, defaultValue float64, evalCtx EvaluationContext, options ...Option) (float64, error)
IntValue(ctx context.Context, flag string, defaultValue int64, evalCtx EvaluationContext, options ...Option) (int64, error)
ObjectValue(ctx context.Context, flag string, defaultValue interface{}, evalCtx EvaluationContext, options ...Option) (interface{}, error)
BooleanValueDetails(ctx context.Context, flag string, defaultValue bool, evalCtx EvaluationContext, options ...Option) (BooleanEvaluationDetails, error)
StringValueDetails(ctx context.Context, flag string, defaultValue string, evalCtx EvaluationContext, options ...Option) (StringEvaluationDetails, error)
FloatValueDetails(ctx context.Context, flag string, defaultValue float64, evalCtx EvaluationContext, options ...Option) (FloatEvaluationDetails, error)
IntValueDetails(ctx context.Context, flag string, defaultValue int64, evalCtx EvaluationContext, options ...Option) (IntEvaluationDetails, error)
ObjectValueDetails(ctx context.Context, flag string, defaultValue interface{}, evalCtx EvaluationContext, options ...Option) (InterfaceEvaluationDetails, error)
}
IClient defines the behaviour required of an openfeature client
type IntEvaluationDetails ¶ added in v0.5.0
type IntEvaluationDetails struct {
Value int64
EvaluationDetails
}
type IntResolutionDetail ¶
type IntResolutionDetail struct {
Value int64
ProviderResolutionDetail
}
IntResolutionDetail provides a resolution detail with int64 type
type InterfaceEvaluationDetails ¶ added in v0.5.0
type InterfaceEvaluationDetails struct {
Value interface{}
EvaluationDetails
}
type InterfaceResolutionDetail ¶
type InterfaceResolutionDetail struct {
Value interface{}
ProviderResolutionDetail
}
InterfaceResolutionDetail provides a resolution detail with interface{} type
type Metadata ¶
type Metadata struct {
Name string
}
Metadata provides provider name
func ProviderMetadata ¶
func ProviderMetadata() Metadata
ProviderMetadata returns the global provider's metadata
type NoopProvider ¶
type NoopProvider struct{}
NoopProvider implements the FeatureProvider interface and provides functions for evaluating flags
func (NoopProvider) BooleanEvaluation ¶
func (e NoopProvider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, evalCtx FlattenedContext) BoolResolutionDetail
BooleanEvaluation returns a boolean flag.
func (NoopProvider) FloatEvaluation ¶
func (e NoopProvider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, evalCtx FlattenedContext) FloatResolutionDetail
FloatEvaluation returns a float flag.
func (NoopProvider) IntEvaluation ¶
func (e NoopProvider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, evalCtx FlattenedContext) IntResolutionDetail
IntEvaluation returns an int flag.
func (NoopProvider) Metadata ¶
func (e NoopProvider) Metadata() Metadata
Metadata returns the metadata of the provider
func (NoopProvider) ObjectEvaluation ¶
func (e NoopProvider) ObjectEvaluation(ctx context.Context, flag string, defaultValue interface{}, evalCtx FlattenedContext) InterfaceResolutionDetail
ObjectEvaluation returns an object flag
func (NoopProvider) StringEvaluation ¶
func (e NoopProvider) StringEvaluation(ctx context.Context, flag string, defaultValue string, evalCtx FlattenedContext) StringResolutionDetail
StringEvaluation returns a string flag.
type Option ¶ added in v0.5.0
type Option func(*EvaluationOptions)
Option applies a change to EvaluationOptions
func WithHookHints ¶ added in v0.5.0
WithHookHints applies provided hook hints.
type ProviderResolutionDetail ¶ added in v0.5.0
type ProviderResolutionDetail struct {
ResolutionError ResolutionError
Reason Reason
Variant string
}
ProviderResolutionDetail is a structure which contains a subset of the fields defined in the EvaluationDetail, representing the result of the provider's flag resolution process see https://github.com/open-feature/spec/blob/main/specification/types.md#resolution-details N.B we could use generics but to support older versions of go for now we will have type specific resolution detail
func (ProviderResolutionDetail) Error ¶ added in v0.5.0
func (p ProviderResolutionDetail) Error() error
func (ProviderResolutionDetail) ResolutionDetail ¶ added in v0.5.0
func (p ProviderResolutionDetail) ResolutionDetail() ResolutionDetail
type Reason ¶ added in v0.5.0
type Reason string
Reason indicates the semantic reason for a returned flag value
type ResolutionDetail ¶
type ResolutionError ¶ added in v0.5.0
type ResolutionError struct {
// contains filtered or unexported fields
}
ResolutionError is an enumerated error code with an optional message
func NewFlagNotFoundResolutionError ¶ added in v0.5.0
func NewFlagNotFoundResolutionError(msg string) ResolutionError
NewFlagNotFoundResolutionError constructs a resolution error with code FLAG_NOT_FOUND
Explanation - The flag could not be found.
func NewGeneralResolutionError ¶ added in v0.5.0
func NewGeneralResolutionError(msg string) ResolutionError
NewGeneralResolutionError constructs a resolution error with code GENERAL
Explanation - The error was for a reason not enumerated above.
func NewInvalidContextResolutionError ¶ added in v0.5.0
func NewInvalidContextResolutionError(msg string) ResolutionError
NewInvalidContextResolutionError constructs a resolution error with code INVALID_CONTEXT
Explanation - The evaluation context does not meet provider requirements.
func NewParseErrorResolutionError ¶ added in v0.5.0
func NewParseErrorResolutionError(msg string) ResolutionError
NewParseErrorResolutionError constructs a resolution error with code PARSE_ERROR
Explanation - An error was encountered parsing data, such as a flag configuration.
func NewProviderNotReadyResolutionError ¶ added in v0.5.0
func NewProviderNotReadyResolutionError(msg string) ResolutionError
NewProviderNotReadyResolutionError constructs a resolution error with code PROVIDER_NOT_READY
Explanation - The value was resolved before the provider was ready.
func NewTargetingKeyMissingResolutionError ¶ added in v0.5.0
func NewTargetingKeyMissingResolutionError(msg string) ResolutionError
NewTargetingKeyMissingResolutionError constructs a resolution error with code TARGETING_KEY_MISSING
Explanation - The provider requires a targeting key and one was not provided in the evaluation context.
func NewTypeMismatchResolutionError ¶ added in v0.5.0
func NewTypeMismatchResolutionError(msg string) ResolutionError
NewTypeMismatchResolutionError constructs a resolution error with code TYPE_MISMATCH
Explanation - The type of the flag value does not match the expected type.
func (ResolutionError) Error ¶ added in v0.5.0
func (r ResolutionError) Error() string
type StringEvaluationDetails ¶ added in v0.5.0
type StringEvaluationDetails struct {
Value string
EvaluationDetails
}
type StringResolutionDetail ¶
type StringResolutionDetail struct {
Value string
ProviderResolutionDetail
}
StringResolutionDetail provides a resolution detail with string type
type UnimplementedHook ¶
type UnimplementedHook struct{}
UnimplementedHook implements all hook methods with empty functions Include UnimplementedHook in your hook struct to avoid defining empty functions e.g.
type MyHook struct {
UnimplementedHook
}
func (UnimplementedHook) After ¶
func (u UnimplementedHook) After(hookContext HookContext, flagEvaluationDetails InterfaceEvaluationDetails, hookHints HookHints) error
func (UnimplementedHook) Before ¶
func (u UnimplementedHook) Before(hookContext HookContext, hookHints HookHints) (*EvaluationContext, error)
func (UnimplementedHook) Error ¶
func (u UnimplementedHook) Error(hookContext HookContext, err error, hookHints HookHints)
func (UnimplementedHook) Finally ¶
func (u UnimplementedHook) Finally(hookContext HookContext, hookHints HookHints)