Documentation
¶
Index ¶
- Variables
- func NewCustomTransport(baseTransport http.RoundTripper, getHeaderFn HeadersFn) *customTransport
- 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 WithAuthRetryStrategy(retryStrategy *backoff.ExponentialBackOff) 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 WithMaxAuthRetries(i int) ConfigOption
- func WithProxyMode(b bool) ConfigOption
- func WithPullInterval(interval uint) ConfigOption
- func WithSeenTargetsClearInterval(interval time.Duration) ConfigOption
- func WithSeenTargetsMaxSize(maxSize int) ConfigOption
- func WithSleeper(sleeper types.Sleeper) 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
- func WithWaitForInitialized(b bool) ConfigOption
- type HeadersFn
- type InitializeTimeoutError
- type NonRetryableAuthError
- type RetryableAuthError
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewCustomTransport ¶ added in v0.1.16
func NewCustomTransport(baseTransport http.RoundTripper, getHeaderFn HeadersFn) *customTransport
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 flagIdentifier
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 WithAuthRetryStrategy ¶ added in v0.1.16
func WithAuthRetryStrategy(retryStrategy *backoff.ExponentialBackOff) ConfigOption
WithAuthRetryStrategy sets the backoff and retry strategy for client authentication requests Mainly used for testing purposes, as the SDKs default backoff strategy should be sufficient for most if not all scenarios.
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 auth and 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 WithMaxAuthRetries ¶ added in v0.1.12
func WithMaxAuthRetries(i int) ConfigOption
WithMaxAuthRetries sets how many times the SDK will retry if authentication fails
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 WithSeenTargetsClearInterval ¶ added in v0.1.25
func WithSeenTargetsClearInterval(interval time.Duration) ConfigOption
WithSeenTargetsClearInterval sets the clearing interval for the seen targets map. By default, the interval is set to 24 hours.
func WithSeenTargetsMaxSize ¶ added in v0.1.25
func WithSeenTargetsMaxSize(maxSize int) ConfigOption
WithSeenTargetsMaxSize sets the maximum size for the seen targets map. The SeenTargetsCache helps to reduce the size of the analytics payload that the SDK sends to the Feature Flags Service. This method allows you to set the maximum number of unique targets that will be stored in the SeenTargets cache. By default, the limit is set to 500,000 unique targets. You can increase this number if you need to handle more than 500,000 targets, which will reduce the payload size but will also increase memory usage.
func WithSleeper ¶ added in v0.1.12
func WithSleeper(sleeper types.Sleeper) ConfigOption
WithSleeper is used to aid in testing functionality that sleeps
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
func WithWaitForInitialized ¶ added in v0.1.12
func WithWaitForInitialized(b bool) ConfigOption
WithWaitForInitialized configures the SDK to block the thread until initialization succeeds or fails
type InitializeTimeoutError ¶ added in v0.1.12
type InitializeTimeoutError struct { }
func (InitializeTimeoutError) Error ¶ added in v0.1.12
func (e InitializeTimeoutError) Error() string
type NonRetryableAuthError ¶ added in v0.1.12
func (NonRetryableAuthError) Error ¶ added in v0.1.12
func (e NonRetryableAuthError) Error() string
type RetryableAuthError ¶ added in v0.1.12
func (RetryableAuthError) Error ¶ added in v0.1.12
func (e RetryableAuthError) Error() string