core

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 7 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 must be a flat map with values one of these values: string, int, float or bool. escapeAttributes function 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 creates a new entity with all fields escaped

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 placeholder for one of these values: [ 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

func DefaultVariation added in v3.1.0

func DefaultVariation() *FlagVariation

DefaultVariation returns default variation

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 - no entity is provided to flagger
	NoEntityProvided Reason = "No entity provided to Flagger"

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

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

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

	// IDIsEmpty - entity id is empty
	IDIsEmpty Reason = "Id is empty"

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

	// KillSwitchEngaged - kill switch engaged
	KillSwitchEngaged Reason = "Kill switch engaged"

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

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

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

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

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

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

	// Default - Default (off) treatment reached
	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) IngestionIntervalDuration

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

IngestionIntervalDuration converts seconds to time.Duration. Prevents interval less than 1

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 creates a copy of SDKInfo

Jump to

Keyboard shortcuts

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