flagger

package module
v0.0.0-...-da1c305 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 15 Imported by: 0

README

Code coverage

Flagger SDK

An opensource Go SDK for feature flagging (feature gating, feature toggles). Documentation available here.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadInitArgs represent bad initialization arguments error
	ErrBadInitArgs = errors.New("bad init arguments")
)
View Source
var (
	// SDKInfo represent meta information. do not modify this!
	SDKInfo = &core.SDKInfo{
		Name:    "golang",
		Version: "3.0.0",
	}
)

Functions

func GetPayload

func GetPayload(codename string, entity *core.Entity) core.Payload

GetPayload return payload for Entity by codename

func GetVariation

func GetVariation(codename string, entity *core.Entity) string

GetVariation return variation for Entity by codename

func Init

func Init(ctx context.Context, args *InitArgs) error

Init represent function for initialize Flagger

func IsEnabled

func IsEnabled(codename string, entity *core.Entity) bool

IsEnabled represent function for check if the flag enabled for Entity by codename

func IsSampled

func IsSampled(codename string, entity *core.Entity) bool

IsEnabled represent function for check if the flag sampled for Entity by codename

func Publish

func Publish(ctx context.Context, entity *core.Entity)

Publish represent function for publishing Entity into Ingestion URL

func SetEntity

func SetEntity(entity *core.Entity)

SetEntity represent function to storing Entity(default like), that will be use instead if any method have no entity

func Shutdown

func Shutdown(timeout time.Duration) bool

func Track

func Track(ctx context.Context, event *core.Event)

Track

Types

type Flagger

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

Flagger represent flagger client implementation

func NewFlagger

func NewFlagger() *Flagger

NewFlagger return the new instance Flagger

func (*Flagger) GetPayload

func (flagger *Flagger) GetPayload(codename string, entity *core.Entity) core.Payload

Returns the payload associated with the treatment assigned to the entity

func (*Flagger) GetVariation

func (flagger *Flagger) GetVariation(codename string, entity *core.Entity) string

Returns the variation assigned to the entity in a multivariate flag

func (*Flagger) Init

func (flagger *Flagger) Init(ctx context.Context, args *InitArgs) error

Init gets FlaggerConfiguration, establishes and maintains SSE connections and initialize Ingester

func (*Flagger) IsEnabled

func (flagger *Flagger) IsEnabled(codename string, entity *core.Entity) bool

Determines if flag is enabled for entity.

func (*Flagger) IsSampled

func (flagger *Flagger) IsSampled(codename string, entity *core.Entity) bool

Determines if entity is within the targeted subpopulations

func (*Flagger) Publish

func (flagger *Flagger) Publish(ctx context.Context, entity *core.Entity)

Explicitly notify Airship about an Entity

func (*Flagger) SetEntity

func (flagger *Flagger) SetEntity(entity *core.Entity)

SetEntity stores an entity in Flagger, which allows omission of entity in other API methods.

If you don't provide __any__ entity to Flagger: - flag functions always resolve with the default variation - Track method doesn't record an event

Rule of thumb: make sure you provided an entity to the Flagger

func (*Flagger) Shutdown

func (flagger *Flagger) Shutdown(timeout time.Duration) bool

Shutdown ingests data(if any), stop ingester and closes SSE connection. Shutdown waits to finish current ingestion request, but no longer than a timeout.

returns true if closed by timeout

func (*Flagger) Track

func (flagger *Flagger) Track(ctx context.Context, event *core.Event)

Simple event tracking API. Entity is an optional parameter if it was set before.

type InitArgs

type InitArgs struct {
	APIKey          string
	SourceURL       string
	BackupSourceURL string
	IngestionURL    string
	SSEURL          string
}

InitArgs represent init arguments for Flagger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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