Documentation ¶
Index ¶
- Variables
- type CfClient
- func (c *CfClient) BoolVariation(key string, target *evaluation.Target, defaultValue bool) (bool, error)
- func (c *CfClient) Close() error
- func (c *CfClient) Environment() string
- func (c *CfClient) IntVariation(key string, target *evaluation.Target, defaultValue int64) (int64, error)
- func (c *CfClient) InterceptAddCluster(ctx context.Context, req *http.Request) error
- func (c *CfClient) IsInitialized() (bool, error)
- func (c *CfClient) JSONVariation(key string, target *evaluation.Target, defaultValue types.JSON) (types.JSON, error)
- func (c *CfClient) NumberVariation(key string, target *evaluation.Target, defaultValue float64) (float64, error)
- func (c *CfClient) StringVariation(key string, target *evaluation.Target, defaultValue string) (string, error)
- type ConfigOption
- func WithCache(cache cache.Cache) ConfigOption
- func WithEventsURL(url string) ConfigOption
- func WithHTTPClient(client *http.Client) ConfigOption
- func WithLogger(logger logger.Logger) ConfigOption
- func WithPullInterval(interval uint) ConfigOption
- func WithStore(store storage.Storage) ConfigOption
- func WithStoreEnabled(val bool) ConfigOption
- func WithStreamEnabled(val bool) ConfigOption
- func WithTarget(target evaluation.Target) ConfigOption
- func WithURL(url string) ConfigOption
Constants ¶
This section is empty.
Variables ¶
var ( errors.New("unauthorized") )ErrUnauthorized =
Functions ¶
This section is empty.
Types ¶
type CfClient ¶
type CfClient struct {
// contains filtered or unexported fields
}
CfClient is the Feature Flag client.
This object evaluates feature flags and communicates with Feature Flag services. Applications should instantiate a single instance for the lifetime of their application and share it wherever feature flags need to be evaluated.
When an application is shutting down or no longer needs to use the CfClient instance, it should call Close() to ensure that all of its connections and goroutines are shut down and that any pending analytics events have been delivered.
func NewCfClient ¶
func NewCfClient(sdkKey string, options ...ConfigOption) (*CfClient, error)
NewCfClient creates a new client instance that connects to CF with the default configuration. For advanced configuration options use ConfigOptions functions
func (*CfClient) BoolVariation ¶
func (c *CfClient) BoolVariation(key string, target *evaluation.Target, defaultValue bool) (bool, error)
BoolVariation returns the value of a boolean feature flag for a given target.
Returns defaultValue if there is an error or if the flag doesn't exist
func (*CfClient) Close ¶
Close shuts down the Feature Flag client. After calling this, the client should no longer be used
func (*CfClient) Environment ¶
Environment returns environment based on authenticated SDK key
func (*CfClient) IntVariation ¶
func (c *CfClient) IntVariation(key string, target *evaluation.Target, defaultValue int64) (int64, error)
IntVariation returns the value of a integer feature flag for a given target.
Returns defaultValue if there is an error or if the flag doesn't exist
func (*CfClient) InterceptAddCluster ¶ added in v0.0.13
InterceptAddCluster adds cluster ID to calls
func (*CfClient) IsInitialized ¶ added in v0.0.5
IsInitialized determines if the client is ready to be used. This is true if it has both authenticated and successfully retrieved flags. If it takes longer than 30 seconds the call will timeout and return an error.
func (*CfClient) JSONVariation ¶
func (c *CfClient) JSONVariation(key string, target *evaluation.Target, defaultValue types.JSON) (types.JSON, error)
JSONVariation returns the value of a feature flag for the given target, allowing the value to be of any JSON type.
Returns defaultValue if there is an error or if the flag doesn't exist
func (*CfClient) NumberVariation ¶
func (c *CfClient) NumberVariation(key string, target *evaluation.Target, defaultValue float64) (float64, error)
NumberVariation returns the value of a float64 feature flag for a given target.
Returns defaultValue if there is an error or if the flag doesn't exist
func (*CfClient) StringVariation ¶
func (c *CfClient) StringVariation(key string, target *evaluation.Target, defaultValue string) (string, error)
StringVariation returns the value of a string feature flag for a given target.
Returns defaultValue if there is an error or if the flag doesn't exist
type ConfigOption ¶
type ConfigOption func(config *config)
ConfigOption is used as return value for advanced client configuration using options pattern
func WithCache ¶
func WithCache(cache cache.Cache) ConfigOption
WithCache set custom cache or predefined one from cache package
func WithEventsURL ¶ added in v0.0.10
func WithEventsURL(url string) ConfigOption
WithEventsURL set eventsURL for communicating with ff server
func WithHTTPClient ¶ added in v0.0.5
func WithHTTPClient(client *http.Client) ConfigOption
WithHTTPClient set http client for use in interactions with ff server
func WithLogger ¶
func WithLogger(logger logger.Logger) ConfigOption
WithLogger set custom logger used in main application
func WithPullInterval ¶
func WithPullInterval(interval uint) ConfigOption
WithPullInterval set pulling interval in minutes
func WithStore ¶
func WithStore(store storage.Storage) ConfigOption
WithStore set custom storage or predefined one from storage package
func WithStoreEnabled ¶ added in v0.0.5
func WithStoreEnabled(val bool) ConfigOption
WithStoreEnabled set store on or off
func WithStreamEnabled ¶
func WithStreamEnabled(val bool) ConfigOption
WithStreamEnabled set stream on or off
func WithTarget ¶ added in v0.0.6
func WithTarget(target evaluation.Target) ConfigOption
WithTarget sets target
func WithURL ¶
func WithURL(url string) ConfigOption
WithURL set baseUrl for communicating with ff server