Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) CurrentSha() string
- func (c *Client) FeatureExists(feature string) bool
- func (c *Client) FeatureMap() *models.FeatureMap
- func (c *Client) Features() models.Features
- 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.Features
- func (sc *StatsClient) Incr(feature string, enabled bool)
- 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)
- type Statter
Constants ¶
const ( Enabled = "enabled" Disabled = "disabled" JoinWith = "." )
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) CurrentSha ¶
CurrentSha accessor for the underlying `CurrentSha` from the `FeatureMap`
func (*Client) FeatureExists ¶
FeatureExists checks the existence of a key
func (*Client) FeatureMap ¶
func (c *Client) FeatureMap() *models.FeatureMap
FeatureMap `featureMap` accessor
func (*Client) IsAvailable ¶
IsAvailable used to check features with boolean values.
func (*Client) IsAvailableForID ¶
IsAvailableForID used to check features with float values between 0.0-1.0.
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. Mostly used for JSON output.
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 with it and spawns the watch in a go routine returning the `Client` for a fluent interface.
func (*Client) WithScopes ¶
WithScopes creates a new Client from an existing one that is "scoped" to the provided scopes param. `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".
The provided `scopes` are appended to the existing Client's `scopes`, merged, and then a new `Watcher` is assigned to the new `Client` so that future changes to the `FeatureMap` will be observed.
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.Features
FeatureMap() *models.FeatureMap
ScopedMap() *models.FeatureMap
Scopes() []string
CurrentSha() string
WithScopes(scopes ...string) *Client
}
IFace interface for Decider Clients
type StatsClient ¶
type StatsClient struct {
Client
// contains filtered or unexported fields
}
func NewStatsClient ¶
func NewStatsClient(cfg *config.Config, stats Statter) (sc *StatsClient)
func (*StatsClient) FeatureExists ¶
func (sc *StatsClient) FeatureExists(feature string) bool
func (*StatsClient) Features ¶
func (sc *StatsClient) Features() models.Features
func (*StatsClient) Incr ¶
func (sc *StatsClient) Incr(feature string, enabled bool)
func (*StatsClient) IsAvailable ¶
func (sc *StatsClient) IsAvailable(feature string) bool
func (*StatsClient) IsAvailableForID ¶
func (sc *StatsClient) IsAvailableForID(feature string, id uint64) bool
func (*StatsClient) ScaleValue ¶
func (sc *StatsClient) ScaleValue(feature string, min float64, max float64) float64
func (*StatsClient) Scopes ¶
func (sc *StatsClient) Scopes() []string
func (*StatsClient) UpdateFeatures ¶
func (sc *StatsClient) UpdateFeatures(bts []byte)