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) GetClusterIdentifier() 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) IsStreamConnected() bool
- 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) PostEvaluateProcessor(data *evaluation.PostEvalData)
- func (c *CfClient) StringVariation(key string, target *evaluation.Target, defaultValue string) (string, error)
- type ConfigOption
- func WithAnalyticsEnabled(val bool) ConfigOption
- func WithCache(cache cache.Cache) ConfigOption
- func WithEventStreamListener(e stream.EventStreamListener) ConfigOption
- func WithEventsURL(url string) ConfigOption
- func WithHTTPClient(client *http.Client) ConfigOption
- func WithLogger(logger logger.Logger) ConfigOption
- func WithProxyMode(b bool) 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) GetClusterIdentifier ¶ added in v0.0.25
GetClusterIdentifier returns the cluster identifier we're connected to
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 ¶
InterceptAddCluster adds cluster ID to calls
func (*CfClient) IsInitialized ¶
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 1 minute the call will timeout and return an error.
func (*CfClient) IsStreamConnected ¶ added in v0.0.24
IsStreamConnected determines if the stream is currently connected
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) PostEvaluateProcessor ¶ added in v0.0.25
func (c *CfClient) PostEvaluateProcessor(data *evaluation.PostEvalData)
PostEvaluateProcessor push the data to the analytics service
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 WithAnalyticsEnabled ¶ added in v0.1.2
func WithAnalyticsEnabled(val bool) ConfigOption
WithAnalyticsEnabled en/disable cache and analytics data being sent.
func WithCache ¶
func WithCache(cache cache.Cache) ConfigOption
WithCache set custom cache or predefined one from cache package
func WithEventStreamListener ¶ added in v0.0.24
func WithEventStreamListener(e stream.EventStreamListener) ConfigOption
WithEventStreamListener configures the SDK to forward Events from the Feature Flag server to the passed EventStreamListener
func WithEventsURL ¶
func WithEventsURL(url string) ConfigOption
WithEventsURL set eventsURL for communicating with ff server
func WithHTTPClient ¶
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 WithProxyMode ¶ added in v0.1.9
func WithProxyMode(b bool) ConfigOption
WithProxyMode should be used when the SDK is being used inside the ff proxy to control the cache and handle sse events
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 ¶
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 WithURL ¶
func WithURL(url string) ConfigOption
WithURL set baseUrl for communicating with ff server