Documentation
¶
Overview ¶
ConfigCat SDK for Go (https://configcat.com)
Index ¶
- Constants
- type Client
- func (client *Client) Close()
- func (client *Client) GetAllKeys() ([]string, error)
- func (client *Client) GetAllKeysAsync(completion func(result []string, err error))
- func (client *Client) GetAllVariationIds() ([]string, error)
- func (client *Client) GetAllVariationIdsAsync(completion func(result []string, err error))
- func (client *Client) GetAllVariationIdsAsyncForUser(user *User, completion func(result []string, err error))
- func (client *Client) GetAllVariationIdsForUser(user *User) ([]string, error)
- func (client *Client) GetKeyAndValue(variationId string) (string, interface{})
- func (client *Client) GetKeyAndValueAsync(variationId string, completion func(key string, value interface{}))
- func (client *Client) GetValue(key string, defaultValue interface{}) interface{}
- func (client *Client) GetValueAsync(key string, defaultValue interface{}, completion func(result interface{}))
- func (client *Client) GetValueAsyncForUser(key string, defaultValue interface{}, user *User, ...)
- func (client *Client) GetValueForUser(key string, defaultValue interface{}, user *User) interface{}
- func (client *Client) GetVariationId(key string, defaultVariationId string) string
- func (client *Client) GetVariationIdAsync(key string, defaultVariationId string, completion func(result string))
- func (client *Client) GetVariationIdAsyncForUser(key string, defaultVariationId string, user *User, ...)
- func (client *Client) GetVariationIdForUser(key string, defaultVariationId string, user *User) string
- func (client *Client) Refresh()
- func (client *Client) RefreshAsync(completion func())
- type ClientConfig
- type ConfigCache
- type DataGovernance
- type LogLevel
- type Logger
- type RefreshMode
- type User
Constants ¶
const ( ConfigJsonName = "config_v5" NoRedirect = 0 ShouldRedirect = 1 ForceRedirect = 2 )
const ( // Fetched indicates that a new configuration was fetched. Fetched fetchStatus = 0 // NotModified indicates that the current configuration is not modified. NotModified fetchStatus = 1 // Failure indicates that the current configuration fetch is failed. Failure fetchStatus = 2 )
const ( LogLevelPanic = LogLevel(logrus.PanicLevel) LogLevelFatal = LogLevel(logrus.FatalLevel) LogLevelError = LogLevel(logrus.ErrorLevel) LogLevelWarn = LogLevel(logrus.WarnLevel) LogLevelInfo = LogLevel(logrus.InfoLevel) LogLevelDebug = LogLevel(logrus.DebugLevel) LogLevelTrace = LogLevel(logrus.TraceLevel) )
Define the logrus log levels
const (
CacheBase = "go_" + ConfigJsonName + "_%s"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an object for handling configurations provided by ConfigCat.
func NewClient ¶
NewClient initializes a new ConfigCat Client with the default configuration. The sdkKey parameter is mandatory.
func NewCustomClient ¶
func NewCustomClient(sdkKey string, config ClientConfig) *Client
NewCustomClient initializes a new ConfigCat Client with advanced configuration. The sdkKey parameter is mandatory.
func (*Client) Close ¶
func (client *Client) Close()
Close shuts down the client, after closing, it shouldn't be used
func (*Client) GetAllKeys ¶
GetAllKeys retrieves all the setting keys.
func (*Client) GetAllKeysAsync ¶
GetAllKeysAsync retrieves all the setting keys asynchronously.
func (*Client) GetAllVariationIds ¶
GetAllVariationIds returns the Variation IDs synchronously as []string from the configuration.
func (*Client) GetAllVariationIdsAsync ¶
GetAllVariationIdsAsync reads and sends a Variation ID asynchronously to a callback function as []string from the configuration.
func (*Client) GetAllVariationIdsAsyncForUser ¶
func (client *Client) GetAllVariationIdsAsyncForUser(user *User, completion func(result []string, err error))
GetAllVariationIdsAsyncForUser reads and sends a Variation ID asynchronously to a callback function as []string from the configuration. Optional user argument can be passed to identify the caller.
func (*Client) GetAllVariationIdsForUser ¶
GetAllVariationIdsForUser returns the Variation IDs synchronously as []string from the configuration. Optional user argument can be passed to identify the caller.
func (*Client) GetKeyAndValue ¶
GetKeyAndValue returns the key of a setting and its value identified by the given Variation ID.
func (*Client) GetKeyAndValueAsync ¶
func (client *Client) GetKeyAndValueAsync(variationId string, completion func(key string, value interface{}))
GetAllVariationIdsAsyncForUser reads and sends the key of a setting and its value identified by the given Variation ID asynchronously to a callback function as (string, interface{}) from the configuration.
func (*Client) GetValue ¶
GetValue returns a value synchronously as interface{} from the configuration identified by the given key.
func (*Client) GetValueAsync ¶
func (client *Client) GetValueAsync(key string, defaultValue interface{}, completion func(result interface{}))
GetValueAsync reads and sends a value asynchronously to a callback function as interface{} from the configuration identified by the given key.
func (*Client) GetValueAsyncForUser ¶
func (client *Client) GetValueAsyncForUser(key string, defaultValue interface{}, user *User, completion func(result interface{}))
GetValueAsyncForUser reads and sends a value asynchronously to a callback function as interface{} from the configuration identified by the given key. Optional user argument can be passed to identify the caller.
func (*Client) GetValueForUser ¶
GetValueForUser returns a value synchronously as interface{} from the configuration identified by the given key. Optional user argument can be passed to identify the caller.
func (*Client) GetVariationId ¶
GetVariationId returns a Variation ID synchronously as string from the configuration identified by the given key.
func (*Client) GetVariationIdAsync ¶
func (client *Client) GetVariationIdAsync(key string, defaultVariationId string, completion func(result string))
GetVariationIdAsync reads and sends a Variation ID asynchronously to a callback function as string from the configuration identified by the given key.
func (*Client) GetVariationIdAsyncForUser ¶
func (client *Client) GetVariationIdAsyncForUser(key string, defaultVariationId string, user *User, completion func(result string))
GetVariationIdAsyncForUser reads and sends a Variation Id asynchronously to a callback function as string from the configuration identified by the given key. Optional user argument can be passed to identify the caller.
func (*Client) GetVariationIdForUser ¶
func (client *Client) GetVariationIdForUser(key string, defaultVariationId string, user *User) string
GetVariationIdForUser returns a Variation ID synchronously as string from the configuration identified by the given key. Optional user argument can be passed to identify the caller.
func (*Client) Refresh ¶
func (client *Client) Refresh()
Refresh initiates a force refresh synchronously on the cached configuration.
func (*Client) RefreshAsync ¶
func (client *Client) RefreshAsync(completion func())
RefreshAsync initiates a force refresh asynchronously on the cached configuration.
type ClientConfig ¶
type ClientConfig struct { // Base logger used to create new loggers Logger Logger // The custom cache implementation used to store the configuration. Cache ConfigCache // The maximum time how long at most the synchronous calls (e.g. client.get(...)) should block the caller. // If it's 0 then the caller will be blocked in case of sync calls, until the operation succeeds or fails. MaxWaitTimeForSyncCalls time.Duration // The maximum wait time for a http response. HttpTimeout time.Duration // The base ConfigCat CDN url. BaseUrl string // The custom http transport object. Transport http.RoundTripper // The refresh mode of the cached configuration. Mode RefreshMode // Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: // https://app.configcat.com/organization/data-governance (Only Organization Admins have access) DataGovernance DataGovernance }
ClientConfig describes custom configuration options for the Client.
type ConfigCache ¶
type ConfigCache interface { // get reads the configuration from the cache. Get(key string) (string, error) // set writes the configuration into the cache. Set(key string, value string) error }
ConfigCache is a cache API used to make custom cache implementations.
type DataGovernance ¶
type DataGovernance int
DataGovernance describes the location of your feature flag and setting data within the ConfigCat CDN.
const ( // Global Select this if your feature flags are published to all global CDN nodes. Global DataGovernance = 0 // EuOnly Select this if your feature flags are published to CDN nodes only in the EU. EuOnly DataGovernance = 1 )
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Debugln(args ...interface{}) Infoln(args ...interface{}) Warnln(args ...interface{}) Errorln(args ...interface{}) }
Logger defines the interface this library logs with.
func DefaultLogger ¶
DefaultLogger creates the default logger with specified log level (logrus.New()).
type RefreshMode ¶
type RefreshMode interface {
// contains filtered or unexported methods
}
func AutoPoll ¶
func AutoPoll(interval time.Duration) RefreshMode
AutoPoll creates an auto polling refresh mode.
func AutoPollWithChangeListener ¶
func AutoPollWithChangeListener( interval time.Duration, changeListener func()) RefreshMode
AutoPollWithChangeListener creates an auto polling refresh mode with change listener callback.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is an object containing attributes to properly identify a given user for rollout evaluation.
func NewUserWithAdditionalAttributes ¶
func NewUserWithAdditionalAttributes(identifier string, email string, country string, custom map[string]string) *User
NewUserWithAdditionalAttributes creates a new user object with additional attributes. The identifier argument is mandatory.
func (*User) GetAttribute ¶
GetAttribute retrieves a user attribute identified by a key.
Source Files
¶
- async.go
- async_result.go
- auto_polling_policy.go
- config_cache.go
- config_fetcher.go
- config_parser.go
- configcat_client.go
- constants.go
- fake_config_provider.go
- fetch_response.go
- lazy_loading_policy.go
- logger.go
- manual_polling_policy.go
- match.go
- refresh_policy.go
- refresh_policy_factory.go
- rollout_evaluator.go
- user.go
- version.go