Documentation ¶
Index ¶
- func APIKey(apiKey string) func(r *APIClient)
- func APIOptions(apiOptions ...func(*APIClient)) func(r *Engine)
- func APIUrl(url string) func(r *APIClient)
- func PollingInterval(interval time.Duration) func(r *Engine)
- func Retries(retries int) func(r *APIClient)
- func TargetingMatch(variationGroup *VariationGroup, visitorID string, ...) (bool, error)
- func Timeout(timeout time.Duration) func(r *APIClient)
- type APIClient
- type APIClientMock
- type Campaign
- type ConfigAPIInterface
- type Configuration
- type Engine
- type EngineOptions
- type Targeting
- type TargetingGroup
- type TargetingOperator
- type TargetingWrapper
- type Variation
- type VariationGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIOptions ¶
APIOptions sets the func option for the engine client API
func PollingInterval ¶
PollingInterval sets the polling interval for the bucketing engine
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
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient represents the API client informations
func NewAPIClient ¶
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"` 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 ¶
Configuration represents a bucketing configuration
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine represents a bucketing engine
func GetBucketingEngineMock ¶
GetBucketingEngineMock returns a bucketing engine with mock config
func (*Engine) GetModifications ¶
func (b *Engine) GetModifications(visitorID string, context map[string]interface{}) (*model.APIClientResponse, error)
GetModifications gets modifications from Decision API
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