flagger

package
v0.0.0-...-2c5242a Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BOOL    flagType = "BOOL"    // BOOL is a simple boolean flag type
	PERCENT flagType = "PERCENT" // PERCENT is a boolean that is true ${PERCENT}% of the time
)

flagTypes are types of flags

Variables

View Source
var ErrFlagNotFound = errors.New("Flag not found")

ErrFlagNotFound means the flag was not found

Functions

This section is empty.

Types

type Flag

type Flag struct {
	Name          string
	Type          flagType `json:"type"`
	InternalValue int      `json:"value"`
	Namespace     string   `json:"namespace"`
	Tags          []string `json:"tags"`
}

Flag is a flag ;)

func (*Flag) MarshalBinary

func (f *Flag) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding support for redis

func (*Flag) UnmarshalBinary

func (f *Flag) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding support for redis

func (*Flag) Value

func (f *Flag) Value() bool

Value returns the calculated flag value

type Flagger

type Flagger interface {
	SaveFlag(flag *Flag) error
	GetFlag(name string) (*Flag, error)
	GetFlagWithTags(name string, tags []string) (*Flag, error)
	ListFlags() ([]*Flag, error)
}

Flagger is implemented by each of the storage backends

func NewRedisFlagger

func NewRedisFlagger(host string, db int) (Flagger, error)

NewRedisFlagger creates a new flagger backed by redis

type RedisFlagger

type RedisFlagger struct {
	// contains filtered or unexported fields
}

RedisFlagger is a redis backed flagger

func (*RedisFlagger) GetFlag

func (rf *RedisFlagger) GetFlag(name string) (*Flag, error)

GetFlag loads a flag without tags

func (*RedisFlagger) GetFlagWithTags

func (rf *RedisFlagger) GetFlagWithTags(name string, tags []string) (*Flag, error)

GetFlagWithTags loads a flag from a redis client

func (*RedisFlagger) ListFlags

func (rf *RedisFlagger) ListFlags() (flags []*Flag, err error)

ListFlags returns a list of flags grouped by name and environment

func (*RedisFlagger) SaveFlag

func (rf *RedisFlagger) SaveFlag(flag *Flag) error

SaveFlag saves a flag to redis

Jump to

Keyboard shortcuts

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