Documentation ¶
Index ¶
- type Client
- func (c *Client) FeatureExists(feature string) bool
- func (c *Client) FeatureMap() *models.FeatureMap
- func (c *Client) Features() models.FeatureScopes
- func (c *Client) Info() *models.Info
- func (c *Client) IsAvailable(feature string) bool
- func (c *Client) IsAvailableForID(feature string, id uint64) bool
- func (c *Client) MergeScopes()
- func (c *Client) ScaleValue(feature string, min float64, max float64) float64
- func (c *Client) ScopedMap() *models.FeatureMap
- func (c *Client) Scopes() []string
- func (c *Client) SetFeatureMap(fm *models.FeatureMap) *Client
- func (c *Client) UpdateFeatures(bts []byte)
- func (c *Client) Watch() (*Client, error)
- func (c *Client) WithScopes(scopes ...string) *Client
- type IFace
- type StatsClient
- func (sc *StatsClient) FeatureExists(feature string) bool
- func (sc *StatsClient) Features() models.FeatureScopes
- func (sc *StatsClient) Incr(feature string, enabled bool, sampleRate float64)
- func (sc *StatsClient) IsAvailable(feature string) bool
- func (sc *StatsClient) IsAvailableForID(feature string, id uint64) bool
- func (sc *StatsClient) ScaleValue(feature string, min float64, max float64) float64
- func (sc *StatsClient) Scopes() []string
- func (sc *StatsClient) UpdateFeatures(bts []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles access to the `FeatureMap`
func (*Client) FeatureExists ¶
FeatureExists checks the existence of a key
func (*Client) FeatureMap ¶
func (c *Client) FeatureMap() *models.FeatureMap
FeatureMap `featureMap` accessor. Returns an empty `FeatureMap` if the `featureMap` is nil.
func (*Client) Features ¶
func (c *Client) Features() models.FeatureScopes
Features `features` accessor
func (*Client) IsAvailable ¶
IsAvailable used to check features with boolean values. Returns false if a non-boolean type `feature` is passed.
func (*Client) IsAvailableForID ¶
IsAvailableForID used to check features with float values between 0.0-1.0. Returns false if a non-percentile type `feature` is passed.
func (*Client) MergeScopes ¶
func (c *Client) MergeScopes()
MergeScopes delegates merging to the underlying `FeatureMap`
func (*Client) ScaleValue ¶
ScaleValue returns a value scaled between min and max given the current value of the feature.
Given the K/V dcdr/features/scalar => 0.5 ScaleValue("scalar", 0, 10) => 5
func (*Client) ScopedMap ¶
func (c *Client) ScopedMap() *models.FeatureMap
ScopedMap a `FeatureMap` containing only merged features and `Info`.
func (*Client) SetFeatureMap ¶
func (c *Client) SetFeatureMap(fm *models.FeatureMap) *Client
SetFeatureMap assigns a `FeatureMap` and merges the current scopes. When git is enabled a new `FeatureMap` will not be assigned unless its `CurrentSHA` is different from the one currently found in `CurrentSHA()`.
func (*Client) UpdateFeatures ¶
UpdateFeatures creates and assigns a new `FeatureMap` from a Marshalled JSON byte array
func (*Client) Watch ¶
Watch initializes the `Watcher`, registers the `UpdateFeatures` method, and spawns the watch in a go routine returning the `Client` for a fluent interface.
func (*Client) WithScopes ¶
WithScopes creates a new Client from `c` that is "scoped" to the provided scopes argument. `scopes` are provided in priority order. For example, when given WithScopes("a", "b", "c"). Keys found in "a" will override the same keys found in "b" and so on for "c".
type IFace ¶
type IFace interface { IsAvailable(feature string) bool IsAvailableForID(feature string, id uint64) bool ScaleValue(feature string, min float64, max float64) float64 UpdateFeatures(bts []byte) FeatureExists(feature string) bool Features() models.FeatureScopes FeatureMap() *models.FeatureMap SetFeatureMap(fm *models.FeatureMap) *Client ScopedMap() *models.FeatureMap Scopes() []string Info() *models.Info WithScopes(scopes ...string) *Client }
IFace interface for Decider Clients
type StatsClient ¶
type StatsClient struct { Client // contains filtered or unexported fields }
StatsClient delegates `Client` methods with metrics.
func NewStatsClient ¶
NewStatsClient creates a new client.
func NewStatsDefault ¶ added in v0.2.2
func NewStatsDefault(stats stats.IFace) (sc *StatsClient, err error)
NewStatsClient creates a new client.
func (*StatsClient) FeatureExists ¶
func (sc *StatsClient) FeatureExists(feature string) bool
FeatureExists delegates `FeatureExists`.
func (*StatsClient) Features ¶
func (sc *StatsClient) Features() models.FeatureScopes
Features delegates `Features`.
func (*StatsClient) Incr ¶
func (sc *StatsClient) Incr(feature string, enabled bool, sampleRate float64)
Incr increments the formatted `statKey`.
func (*StatsClient) IsAvailable ¶
func (sc *StatsClient) IsAvailable(feature string) bool
IsAvailable delegates `IsAvailable` and increments the provided `feature` status.
func (*StatsClient) IsAvailableForID ¶
func (sc *StatsClient) IsAvailableForID(feature string, id uint64) bool
IsAvailableForID delegates `IsAvailableForID` and increments the provided `feature` status.
func (*StatsClient) ScaleValue ¶
func (sc *StatsClient) ScaleValue(feature string, min float64, max float64) float64
ScaleValue delegates `ScaleValue`.
func (*StatsClient) UpdateFeatures ¶
func (sc *StatsClient) UpdateFeatures(bts []byte)
UpdateFeatures delegates `UpdateFeatures`.