core

package
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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashMD5

func HashMD5(id string) float64

HashMD5 represent hash function for sampling subpopulation and choose variation

Types

type Attributes

type Attributes map[string]interface{}

Attributes IMPORTANT: this map values type should be: string, int, float or bool. escapeAttributes function below satisfies this invariant

type Configuration

type Configuration struct {
	HashKey   string        `json:"hashKey"`
	Flags     []*FlagConfig `json:"flags"`
	SdkConfig SDKConfig     `json:"sdkConfig,omitempty"`
}

Configuration represent flagger configuration

func (*Configuration) Escape

func (c *Configuration) Escape()

Escape represent method for escaping configuration

type Core

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

Core represent things for encapsulate business logic for flags calculation

func NewCore

func NewCore() *Core

NewCore return the new instance Core

func (*Core) EvaluateFlag

func (core *Core) EvaluateFlag(codename string, entity *Entity) *FlagResult

EvaluateFlag represent method for calculation Flag for Entity by codename

func (*Core) GetEntity

func (core *Core) GetEntity() *Entity

GetEntity represent method for return stored Entity

func (*Core) SetConfig

func (core *Core) SetConfig(v *Configuration)

SetConfig represent callback function for insert incoming configuration

func (*Core) SetEntity

func (core *Core) SetEntity(v *Entity)

SetEntity represent function from main Flagger interface

type Entity

type Entity struct {
	ID         string     `json:"id"`
	Type       string     `json:"type,omitempty"`
	Name       string     `json:"name,omitempty"`
	Variation  string     `json:"variation,omitempty"` // used only in whitelist
	Group      *Group     `json:"group,omitempty"`
	Attributes Attributes `json:"attributes,omitempty"`
}

Entity represent flagger entity

func EscapeEntity

func EscapeEntity(e *Entity) *Entity

EscapeEntity represent method for escaping Entity

type Event

type Event struct {
	Name            string     `json:"name"`
	EventProperties Attributes `json:"eventProperties"`
	Entity          *Entity    `json:"entity,omitempty"`
}

Event represent flagger event

func EscapeEvent

func EscapeEvent(event *Event) *Event

EscapeEvent represent method for escaping event

type Exposure

type Exposure struct {
	Codename     string    `json:"codename"`
	HashKey      string    `json:"hashkey,omitempty"`
	Variation    string    `json:"variation"`
	Entity       *Entity   `json:"entity"`
	MethodCalled string    `json:"methodCalled"`
	Timestamp    time.Time `json:"timestamp"`
}

Exposure represent flagger exposure

type FilterValue

type FilterValue interface{}

FilterValue IMPORTANT: this object must be on of: [ int | float | string | bool | []int, []float | []string | []bool ]

type FlagConfig

type FlagConfig struct {
	Codename           string               `json:"codename"`
	KillSwitchEngaged  bool                 `json:"killSwitchEngaged,omitempty"`
	HashKey            string               `json:"hashkey,omitempty"`
	Variations         []*FlagVariation     `json:"variations,omitempty"`
	FlagSubPopulations []*FlagSubpopulation `json:"subpopulations,omitempty"`
	Blacklist          []*Entity            `json:"blacklist,omitempty"`
	Whitelist          []*Entity            `json:"whitelist,omitempty"`
}

FlagConfig represent flagger flag configuration

type FlagFilter

type FlagFilter struct {
	AttributeName string      `json:"attributeName"`
	Operator      Operator    `json:"operator"`
	Value         FilterValue `json:"value"`
	FilterType    string      `json:"type"`
}

FlagFilter represent one flag filter entity

type FlagResult

type FlagResult struct {
	Hashkey   string
	Entity    *Entity
	Enabled   bool
	Sampled   bool
	Variation *FlagVariation
	Payload   Payload
	IsNew     bool
	Reason    Reason
}

FlagResult represent calculated flag result

type FlagSubpopulation

type FlagSubpopulation struct {
	EntityType         string        `json:"entityType"`
	SamplingPercentage float64       `json:"samplingPercentage"`
	Filters            []*FlagFilter `json:"filters"`
}

FlagSubpopulation represent subpopulation entity of Flag

type FlagVariation

type FlagVariation struct {
	Codename    string  `json:"codename"`
	Probability float64 `json:"probability"`
	Payload     Payload `json:"payload"`
}

FlagVariation represent variation entity of Flag

type Group

type Group struct {
	ID         string     `json:"id"`
	Type       string     `json:"type,omitempty"`
	Name       string     `json:"name,omitempty"`
	Attributes Attributes `json:"attributes,omitempty"`
}

Group represent flagger group from entities

type Operator

type Operator string

Operator represent filter operator

type Payload

type Payload map[string]interface{}

Payload represent Flag payload

type Reason

type Reason string

Reason represent type of flag reason

const (
	// NoEntityProvided represent flag reason for witch have no entity for calculating
	NoEntityProvided Reason = "No entity provided to Flagger"

	// ConfigIsEmpty
	FlaggerIsNotInitialized Reason = "Flagger is not initialized"

	// ConfigIsEmpty
	ConfigIsEmpty Reason = "No flags in the current config"

	// CodenameIsEmpty
	CodenameIsEmpty Reason = "Flag codename is empty"

	// IdIsEmpty
	IdIsEmpty Reason = "Id is empty"

	// FlagNotInConfig
	FlagNotInConfig Reason = "Flag is not in the current config"

	// KillSwitchEngaged
	KillSwitchEngaged Reason = "Kill switch engaged"

	// IndividualBlacklist
	IndividualBlacklist Reason = "Entity is individually blacklisted"

	// IndividualWhitelist
	IndividualWhitelist Reason = "Entity is individually whitelisted"

	// GroupBlacklist
	GroupBlacklist Reason = "Entity's group is blacklisted"

	// GroupWhitelist
	GroupWhitelist Reason = "Entity's group is whitelisted"

	// IsSampled
	IsSampled Reason = "Entity is sampled in the individual subpopulation"

	// IsSampledByGroup
	IsSampledByGroup Reason = "Entity is sampled in the group subpopulation"

	// Default
	Default Reason = "Default (off) treatment reached"
)

type SDKConfig

type SDKConfig struct {
	SDKIngestionInterval int `json:"SDK_INGESTION_INTERVAL,omitempty"`
	SDKIngestionMaxItems int `json:"SDK_INGESTION_MAX_CALLS,omitempty"`
}

SDKConfig represent flagger SDK configuration

func (*SDKConfig) Copy

func (s *SDKConfig) Copy() *SDKConfig

Copy return copy instance SDKConfig

func (*SDKConfig) Equal

func (s *SDKConfig) Equal(v2 *SDKConfig) bool

EqualExceptLogLevel method for compare SDKConfig

func (*SDKConfig) IngestionIntervalDuration

func (s *SDKConfig) IngestionIntervalDuration() time.Duration

type SDKInfo

type SDKInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

SDKInfo represent flagger SDK information

func (*SDKInfo) Copy

func (s *SDKInfo) Copy() *SDKInfo

Copy

Jump to

Keyboard shortcuts

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