bucketing

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIKey

func APIKey(apiKey string) func(r *APIClient)

APIKey sets http client api key

func APIOptions

func APIOptions(apiOptions ...func(*APIClient)) func(r *Engine)

APIOptions sets the func option for the engine client API

func APIUrl

func APIUrl(url string) func(r *APIClient)

APIUrl sets http client base URL

func PollingInterval

func PollingInterval(interval time.Duration) func(r *Engine)

PollingInterval sets the polling interval for the bucketing engine

func Retries

func Retries(retries int) func(r *APIClient)

Retries sets max number of retries for failed calls

func TargetingMatch

func TargetingMatch(variationGroup *VariationGroup, visitorID string, context map[string]interface{}) (bool, error)

TargetingMatch returns true if a visitor ID and context match the variationGroup targeting

func Timeout

func Timeout(timeout time.Duration) func(r *APIClient)

Timeout sets http client timeout

Types

type APIClient

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

APIClient represents the API client informations

func NewAPIClient

func NewAPIClient(envID string, params ...func(*APIClient)) *APIClient

NewAPIClient creates a bucketing API Client to poll bucketing infos

func (*APIClient) GetConfiguration

func (r *APIClient) GetConfiguration() (*Configuration, error)

GetConfiguration gets an environment configuration from bucketing file

type APIClientMock

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

APIClientMock represents the API client mock informations

func NewAPIClientMock

func NewAPIClientMock(envID string, responseMock *Configuration, statusCode int) *APIClientMock

NewAPIClientMock creates a fake api client that returns a specific response

func (*APIClientMock) GetConfiguration

func (r *APIClientMock) GetConfiguration() (*Configuration, error)

GetConfiguration mocks a configuration

type Campaign

type Campaign struct {
	ID              string            `json:"id"`
	CustomID        string            `json:"custom_id"`
	Type            string            `json:"type"`
	VariationGroups []*VariationGroup `json:"variationGroups"`
}

Campaign represents a bucketing campaign

type ConfigAPIInterface

type ConfigAPIInterface interface {
	GetConfiguration() (*Configuration, error)
}

ConfigAPIInterface manage the bucketing configuration

type Configuration

type Configuration struct {
	Panic     bool        `json:"panic"`
	Campaigns []*Campaign `json:"campaigns"`
}

Configuration represents a bucketing configuration

type Engine

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

Engine represents a bucketing engine

func GetBucketingEngineMock

func GetBucketingEngineMock(testEnvID string, cache cache.Manager) *Engine

GetBucketingEngineMock returns a bucketing engine with mock config

func NewEngine

func NewEngine(envID string, cacheManager cache.Manager, params ...func(*Engine)) (*Engine, error)

NewEngine creates a new engine for bucketing

func (*Engine) GetModifications

func (b *Engine) GetModifications(visitorID string, anonymousID *string, context map[string]interface{}) (*model.APIClientResponse, error)

GetModifications gets modifications from Decision API

func (*Engine) Load

func (b *Engine) Load() error

Load loads the env configuration in cache

type EngineOptions

type EngineOptions struct {
	// PollingInterval is the number of milliseconds between each poll. If -1, then no polling will be done
	PollingInterval time.Duration
}

EngineOptions represents the options for the Bucketing decision mode

type Targeting

type Targeting struct {
	Operator TargetingOperator `json:"operator"`
	Key      string            `json:"key"`
	Value    interface{}       `json:"value"`
}

Targeting represents a bucketing targeting group ('or' linked targetings)

type TargetingGroup

type TargetingGroup struct {
	Targetings []*Targeting `json:"targetings"`
}

TargetingGroup represents a bucketing targeting group ('or' linked targetings)

type TargetingOperator

type TargetingOperator string

TargetingOperator express a targeting operator

const (
	NULL                   TargetingOperator = "NULL"
	LOWER_THAN             TargetingOperator = "LOWER_THAN"
	GREATER_THAN_OR_EQUALS TargetingOperator = "GREATER_THAN_OR_EQUALS"
	LOWER_THAN_OR_EQUALS   TargetingOperator = "LOWER_THAN_OR_EQUALS"
	EQUALS                 TargetingOperator = "EQUALS"
	NOT_EQUALS             TargetingOperator = "NOT_EQUALS"
	STARTS_WITH            TargetingOperator = "STARTS_WITH"
	ENDS_WITH              TargetingOperator = "ENDS_WITH"
	CONTAINS               TargetingOperator = "CONTAINS"
	NOT_CONTAINS           TargetingOperator = "NOT_CONTAINS"
	GREATER_THAN           TargetingOperator = "GREATER_THAN"
)

The different targeting operators

type TargetingWrapper

type TargetingWrapper struct {
	TargetingGroups []*TargetingGroup `json:"targetingGroups"`
}

TargetingWrapper represents a bucketing targeting wrapper

type Variation

type Variation struct {
	ID            string             `json:"id"`
	Modifications model.Modification `json:"modifications"`
	Allocation    int                `json:"allocation"`
	Reference     bool               `json:"reference"`
}

Variation represents a bucketing variation

func GetRandomAllocation

func GetRandomAllocation(visitorID string, variationGroup *VariationGroup) (*Variation, error)

GetRandomAllocation returns a random allocation for a variationGroup

type VariationGroup

type VariationGroup struct {
	ID         string           `json:"id"`
	Targeting  TargetingWrapper `json:"targeting"`
	Variations []*Variation     `json:"variations"`
}

VariationGroup represents a bucketing variation group

Jump to

Keyboard shortcuts

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