Documentation
¶
Index ¶
- type Context
- type CustomAttributes
- type Evaluation
- type EvaluationResponse
- type Option
- type Options
- type Toggle
- func (t *Toggle) Get(ctx context.Context, toggleKey string, defaultValue interface{}, ...) (interface{}, error)
- func (t *Toggle) GetBoolean(ctx context.Context, toggleKey string, defaultValue bool, ...) bool
- func (t *Toggle) GetNumber(ctx context.Context, toggleKey string, defaultValue float64, ...) float64
- func (t *Toggle) GetObject(ctx context.Context, toggleKey string, defaultValue map[string]interface{}, ...) map[string]interface{}
- func (t *Toggle) GetString(ctx context.Context, toggleKey string, defaultValue string, ...) string
- func (t *Toggle) SetErrorHandler(handler func(error))
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
TargetingKey string `json:"targetingKey,omitempty"`
IPAddress string `json:"ipAddress,omitempty"`
CustomAttributes CustomAttributes `json:"customAttributes,omitempty"`
User *User `json:"user,omitempty"`
}
Context represents the evaluation context for feature toggle evaluation
type CustomAttributes ¶
type CustomAttributes map[string]interface{}
CustomAttributes represents custom key-value pairs for evaluation context
type Evaluation ¶
type Evaluation struct {
Key string `json:"key"`
Value interface{} `json:"value"`
Type string `json:"type"`
Reason interface{} `json:"reason,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
}
Evaluation represents a single toggle evaluation result
type EvaluationResponse ¶
type EvaluationResponse struct {
Toggles map[string]Evaluation `json:"toggles"`
}
EvaluationResponse represents the response from the toggle evaluation API
type Option ¶
type Option func(*Options)
Option is a functional option for configuring the Toggle client
func WithApplicationID ¶
WithApplicationID sets the application ID for toggle evaluation
func WithDefaultContext ¶
WithDefaultContext sets the default evaluation context
func WithDefaultTargetingKey ¶
WithDefaultTargetingKey sets the default targeting key
func WithEnvironment ¶
WithEnvironment sets the environment (e.g., "development", "production")
func WithHorizonURLs ¶
WithHorizonURLs sets custom Horizon API URLs
func WithPublicAPIKey ¶
WithPublicAPIKey sets the public API key for authentication
type Options ¶
type Options struct {
PublicAPIKey string
ApplicationID string
Environment string
DefaultContext *Context
HorizonURLs []string
DefaultTargetingKey string
}
Options represents configuration options for the Toggle client
type Toggle ¶
type Toggle struct {
// contains filtered or unexported fields
}
Toggle is the client for feature flag management
func (*Toggle) Get ¶
func (t *Toggle) Get(ctx context.Context, toggleKey string, defaultValue interface{}, contextOverride *Context) (interface{}, error)
Get retrieves a toggle value with generic type support
func (*Toggle) GetBoolean ¶
func (t *Toggle) GetBoolean(ctx context.Context, toggleKey string, defaultValue bool, contextOverride *Context) bool
GetBoolean retrieves a boolean toggle value
func (*Toggle) GetNumber ¶
func (t *Toggle) GetNumber(ctx context.Context, toggleKey string, defaultValue float64, contextOverride *Context) float64
GetNumber retrieves a number toggle value (returns float64)
func (*Toggle) GetObject ¶
func (t *Toggle) GetObject(ctx context.Context, toggleKey string, defaultValue map[string]interface{}, contextOverride *Context) map[string]interface{}
GetObject retrieves an object toggle value
func (*Toggle) GetString ¶
func (t *Toggle) GetString(ctx context.Context, toggleKey string, defaultValue string, contextOverride *Context) string
GetString retrieves a string toggle value
func (*Toggle) SetErrorHandler ¶
SetErrorHandler sets a custom error handler function