client

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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 New

func New(cfg *config.Config) (c *Client)

New creates a new Client with a custom Config

func NewDefault

func NewDefault() (c *Client)

NewDefault creates a new default Client

func (*Client) CurrentSha

func (c *Client) CurrentSha() string

CurrentSha accessor for the underlying `CurrentSha` from the `FeatureMap`

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

func (*Client) Features

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

Features `features` accessor

func (*Client) IsAvailable

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

IsAvailable used to check features with boolean values.

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.

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. Mostly used for JSON output.

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 with it 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 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)

type Statter

type Statter interface {
	Incr(feature string)
	Tags() []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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