featuretoggle

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNumber added in v1.1.0

func GetNumber(key string, defaultVal float64) float64

GetNumber returns the number value for the given key.

returns the default value if:

- the library was not initiated;

- the key was not found;

- the key value is empty;

- the key value is not a boolean.

func GetString added in v1.1.0

func GetString(key string, defaultVal string) string

GetString returns the string value for the given key.

returns the default value if:

- the library was not initiated;

- the key was not found;

- the key value is empty.

func Init

func Init(c Config) error

Init inits the feature toggle library

func IsEnabled

func IsEnabled(key string, defaultVal bool) (b bool)

IsEnabled checks if given feature key is enabled in redis DB.

returns the default value if:

- the library was not initiated;

- the key was not found;

- the key value is empty;

- the key value is not a boolean.

func IsEnabledByPercent added in v1.1.0

func IsEnabledByPercent(key string) bool

IsEnabledByPercent checks the redis key value for a percentage number (between 0 and 100), calculates an random number (also between 0 and 100), and returns true or false depending whether the calculated number is within the found percentage.

returns false if:

- the library was not initiated;

- the key was not found;

- the key value is empty;

- the key value is not a percentage (number between 0 and 100);

- the random number greater than the found percentage.

func Mock added in v1.1.1

func Mock(keys map[string]string)

Mock mocks the feature toggle library, will use the keys provided as a param when acessing the feature toggles. Used for testing

func Reset added in v1.2.0

func Reset()

Reset resets the mock library to its empty state.

Types

type Config added in v1.1.0

type Config struct {
	Host        string
	Port        string
	DB          int
	ServiceName string
}

Config represents the feature toggle configuration

Jump to

Keyboard shortcuts

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