Documentation
¶
Index ¶
- func GetFlagValue(featureFlagKey string, defaultValueOptional ...interface{}) interface{}
- func GetFlagValueForTraits(featureFlagKey string, traits interface{}, defaultValueOptional ...interface{}) interface{}
- func GetFlagValueForUser(featureFlagKey string, user User, defaultValueOptional ...interface{}) interface{}
- func Initialize(envKey string)
- func InitializeCustomCacheExpiry(envKey string, expirationTime time.Duration)
- func IsEnabled(featureFlagKey string, defaultValueOptional ...bool) bool
- func IsEnabledForTraits(featureFlagKey string, traits interface{}, defaultValueOptional ...bool) bool
- func IsEnabledForUser(featureFlagKey string, user User, defaultValueOptional ...bool) bool
- type FeatureFlags
- type RequestBody
- type RequestResponseBody
- type User
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFlagValue ¶ added in v0.0.9
func GetFlagValue(featureFlagKey string, defaultValueOptional ...interface{}) interface{}
Fetches the flag value using the provided key
featureFlagKey (string) Key to be used when fetching the feature flag
defaultValueOptional (interface{}) Backup value to be used in case the feature flag isn't found in the current dataset, by default this is nil
func GetFlagValueForTraits ¶ added in v0.0.9
func GetFlagValueForTraits(featureFlagKey string, traits interface{}, defaultValueOptional ...interface{}) interface{}
Fetches the flag value using the provided feature flag key for the specified traits. Use when your flag value is of any other type supported by HappyKit. This function does not use a cache.
featureFlagKey (string) Key to be used when fetching the feature flag
defaultValueOptional (interface{}) Backup value to be used in case the feature flag isn't found in the current dataset, by default this is nil
func GetFlagValueForUser ¶ added in v0.0.9
func GetFlagValueForUser(featureFlagKey string, user User, defaultValueOptional ...interface{}) interface{}
Fetches the flag value using the provided key for the specified user. Use when your flag value is of any other type supported by HappyKit. This function does not use a cache.
featureFlagKey (string) Key to be used when fetching the feature flag
defaultValueOptional (interface{}) Backup value to be used in case the feature flag isn't found in the current dataset, by default this is nil
func Initialize ¶ added in v0.0.9
func Initialize(envKey string)
Initialze function to set and store the environment key for all future calls to HappyKit
func InitializeCustomCacheExpiry ¶ added in v0.0.9
Initialze function to set and store the environment key for all future calls to HappyKit with a custom cache expiration time
func IsEnabled ¶
Returns the boolean value of the provided feature flag key
featureFlagKey (string) Key to be used when fetching the feature flag
defaultValueOptional (bool) Backup value to be used in case the feature flag isn't found in the current dataset
func IsEnabledForTraits ¶ added in v0.0.9
func IsEnabledForTraits(featureFlagKey string, traits interface{}, defaultValueOptional ...bool) bool
Checks if the flag is enabled for the specified traits. Use only when the flag expected is a boolean type
featureFlagKey (string) Key to be used when fetching the feature flag
user (User) User object to be used in the fetch
defaultValueOptional (bool) Backup value to be used in case the feature flag isn't found in the current dataset
func IsEnabledForUser ¶ added in v0.0.9
Checks if the flag is enabled for a specified user. Use only when the flag expected is a boolean type
featureFlagKey (string) Key to be used when fetching the feature flag
user (User) User object to be used in the fetch
defaultValueOptional (bool) Backup value to be used in case the feature flag isn't found in the current dataset
Types ¶
type FeatureFlags ¶
type FeatureFlags map[string]interface{}
func FetchFeatureFlags ¶
func FetchFeatureFlags() (FeatureFlags, bool)
Fetches the feature flags from the api without any extra paramaters
func FetchFeatureFlagsForTraits ¶ added in v0.0.9
func FetchFeatureFlagsForTraits(traits interface{}) (FeatureFlags, bool)
Fetches flags from the api using the provided traits
func FetchFeatureFlagsForUser ¶ added in v0.0.9
func FetchFeatureFlagsForUser(user User) (FeatureFlags, bool)
Fetches the feature flags from the api for the specified user
type RequestBody ¶ added in v0.0.9
type RequestBody struct {
User User `json:"user,omitempty"`
Visitor Visitor `json:"visitorKey,omitempty"`
Traits interface{} `json:"traits,omitempty"`
}
Request body to be sent to HappyKit for complex flag requests
type RequestResponseBody ¶
type RequestResponseBody struct {
Flags FeatureFlags
}
type User ¶ added in v0.0.9
type User struct {
Key string `json:"key"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
Avatar string `json:"avatar,omitempty"`
Country string `json:"country,omitempty"`
}
A user struct used to pass to the API
key (string) (required): Unique key for this user
email (string): Email-Address
name (string): Full name or nickname
avatar (string): URL to users profile picture
country (string): Two-letter uppercase country-code, see ISO 3166-1