client

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 New

func New(cfg *config.Config) (c *Client, err error)

New creates a new Client with a custom Config

func NewDefault

func NewDefault() (c *Client, err error)

NewDefault creates a new default Client

func (*Client) FeatureExists

func (c *Client) FeatureExists(feature string) bool

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) Info added in v0.2.4

func (c *Client) Info() *models.Info

Info accessor for the underlying `Info` from `FeatureMap`

func (*Client) IsAvailable

func (c *Client) IsAvailable(feature string) bool

IsAvailable used to check features with boolean values. Returns false if a non-boolean type `feature` is passed.

func (*Client) IsAvailableForID

func (c *Client) IsAvailableForID(feature string, id uint64) bool

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

func (c *Client) ScaleValue(feature string, min float64, max float64) float64

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) Scopes

func (c *Client) Scopes() []string

Scopes `scopes` accessor

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

func (c *Client) UpdateFeatures(bts []byte)

UpdateFeatures creates and assigns a new `FeatureMap` from a Marshalled JSON byte array

func (*Client) Watch

func (c *Client) Watch() (*Client, error)

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

func (c *Client) WithScopes(scopes ...string) *Client

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

func NewStatsClient(cfg *config.Config, stats stats.IFace) (sc *StatsClient, err error)

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) Scopes

func (sc *StatsClient) Scopes() []string

Scopes delegates `Scopes`.

func (*StatsClient) UpdateFeatures

func (sc *StatsClient) UpdateFeatures(bts []byte)

UpdateFeatures delegates `UpdateFeatures`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL