fflag

package
v0.0.0-...-4122671 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("a flag with that key already exists")
View Source
var ErrNotFound = errors.New("no flag found")

Functions

This section is empty.

Types

type Flag

type Flag struct {
	Key          string                 `json:"key"`
	Type         FlagType               `json:"type"`
	IsPublic     bool                   `json:"isPublic"`
	BooleanValue *bool                  `json:"booleanValue,omitempty"`
	StringValue  *string                `json:"stringValue,omitempty"`
	JSONValue    map[string]interface{} `json:"jsonValue,omitempty"`
}

func (*Flag) Validate

func (flag *Flag) Validate() error

type FlagType

type FlagType string
const (
	FlagTypeString  FlagType = "string"
	FlagTypeBoolean FlagType = "boolean"
	FlagTypeJSON    FlagType = "json"
)

type Repo

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

func NewRepo

func NewRepo(db *sql.DB) Repo

func (*Repo) Create

func (repo *Repo) Create(ctx context.Context, flag Flag) (Flag, error)

func (*Repo) Delete

func (repo *Repo) Delete(ctx context.Context, key string) error

func (*Repo) FindAll

func (repo *Repo) FindAll(ctx context.Context) ([]Flag, error)

func (*Repo) FindOneByKey

func (repo *Repo) FindOneByKey(ctx context.Context, key string) (Flag, error)

func (*Repo) Update

func (repo *Repo) Update(ctx context.Context, flag Flag) (Flag, error)

type Service

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

func NewService

func NewService(repo Repo) Service

func (*Service) Create

func (service *Service) Create(ctx context.Context, flag Flag) (Flag, error)

func (*Service) CreateBooleanFlag

func (service *Service) CreateBooleanFlag(ctx context.Context, booleanFlag UpsertFlagParams[bool]) (Flag, error)

func (*Service) CreateJSONFlag

func (service *Service) CreateJSONFlag(ctx context.Context, jsonFlag UpsertFlagParams[map[string]interface{}]) (Flag, error)

func (*Service) CreateStringFlag

func (service *Service) CreateStringFlag(ctx context.Context, stringFlag UpsertFlagParams[string]) (Flag, error)

func (*Service) Delete

func (service *Service) Delete(ctx context.Context, key string) error

func (*Service) FindAll

func (service *Service) FindAll(ctx context.Context) ([]Flag, error)

func (*Service) FindOne

func (service *Service) FindOne(ctx context.Context, key string) (Flag, error)

func (*Service) Update

func (service *Service) Update(ctx context.Context, flag Flag) (Flag, error)

type UpsertFlagParams

type UpsertFlagParams[T any] struct {
	// Key is the flag's key.  It must be unique, non-empty, and contain only
	// numbers, letters, underscores and hyphens.  It is immutable.
	Key string `json:"key"`

	// IsPublic determines whether the flag is public or not.
	IsPublic bool `json:"isPublic"`

	// Value is the flag's initial value.
	Value T `json:"value"`
}

UpsertFlagParams is the set of parameters required to create a feature flag.

Jump to

Keyboard shortcuts

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