gotoggle

package module
v0.0.0-...-5cdf122 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 18 Imported by: 0

README

WIP

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled(feature string, options ...FeatureOption) bool

func Init

func Init(provider FeatureProvider, options ...ConfigOption)

func UpdateDefault

func UpdateDefault(from *FeatureManager)

Types

type ConfigOption

type ConfigOption func(*configOption)

func WithRepository

func WithRepository(repository StateRepository) ConfigOption

type Feature

type Feature struct {
	Name         string       `json:"name"`
	DefaultState FeatureState `json:"defaultState"`
}

type FeatureManager

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

func NewFeatureManager

func NewFeatureManager(provider FeatureProvider, options ...ConfigOption) *FeatureManager

func (*FeatureManager) Enabled

func (m *FeatureManager) Enabled(feature string, options ...FeatureOption) bool

func (*FeatureManager) Features

func (m *FeatureManager) Features() []string

func (*FeatureManager) NewHandler

func (m *FeatureManager) NewHandler() http.Handler

type FeatureOption

type FeatureOption func(*featureOption)

func WithContext

func WithContext(ctx context.Context) FeatureOption

type FeatureProvider

type FeatureProvider func() []Feature

type FeatureState

type FeatureState struct {
	Name           string                 `json:"name"`
	Enabled        bool                   `json:"enabled"`
	Description    string                 `json:"description"`
	Strategy       string                 `json:"strategy"`
	StrategyParams map[string]interface{} `json:"strategyParams"`
	Updated        time.Time              `json:"updated"`
}

type Handler

type Handler interface {
	http.Handler
}

type StateRepository

type StateRepository interface {
	GetState(ctx context.Context, name string) (*FeatureState, error)
	SetState(ctx context.Context, feature *FeatureState) error
}

func DatabaseStateRepository

func DatabaseStateRepository(database *sql.DB, tableName string) StateRepository

func InMemoryStateRepository

func InMemoryStateRepository() StateRepository

func RedisStateRepository

func RedisStateRepository(client *redis.Client) StateRepository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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