config

package
v1.3.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Overview

Package config //

Package config //

Package config //

Package config //

Index

Constants

View Source
const AuthDatafileURLTemplate = "https://config.optimizely.com/datafiles/auth/%s.json"

AuthDatafileURLTemplate is used to construct the endpoint for retrieving authenticated datafile from the CDN

View Source
const DatafileURLTemplate = "https://cdn.optimizely.com/datafiles/%s.json"

DatafileURLTemplate is used to construct the endpoint for retrieving regular datafile from the CDN

View Source
const DefaultPollingInterval = 5 * time.Minute // default to 5 minutes for polling

DefaultPollingInterval sets default interval for polling manager

View Source
const LastModified = "Last-Modified"

LastModified header key for response

View Source
const ModifiedSince = "If-Modified-Since"

ModifiedSince header key for request

Variables

View Source
var Err403Forbidden = errors.New("unable to fetch fresh datafile (consider rechecking SDK key), status code: 403 Forbidden")

Err403Forbidden is 403Forbidden specific error

Functions

This section is empty.

Types

type OptimizelyConfig

type OptimizelyConfig struct {
	Revision       string                          `json:"revision"`
	ExperimentsMap map[string]OptimizelyExperiment `json:"experimentsMap"`
	FeaturesMap    map[string]OptimizelyFeature    `json:"featuresMap"`
}

OptimizelyConfig is a snapshot of the experiments and features in the project config

func NewOptimizelyConfig

func NewOptimizelyConfig(projConfig ProjectConfig) *OptimizelyConfig

NewOptimizelyConfig constructs OptimizelyConfig object

type OptimizelyExperiment

type OptimizelyExperiment struct {
	ID            string                         `json:"id"`
	Key           string                         `json:"key"`
	VariationsMap map[string]OptimizelyVariation `json:"variationsMap"`
}

OptimizelyExperiment has experiment info

type OptimizelyFeature

type OptimizelyFeature struct {
	ID             string                          `json:"id"`
	Key            string                          `json:"key"`
	ExperimentsMap map[string]OptimizelyExperiment `json:"experimentsMap"`
	VariablesMap   map[string]OptimizelyVariable   `json:"variablesMap"`
}

OptimizelyFeature has feature info

type OptimizelyVariable

type OptimizelyVariable struct {
	ID    string `json:"id"`
	Key   string `json:"key"`
	Type  string `json:"type"`
	Value string `json:"value"`
}

OptimizelyVariable has variable info

type OptimizelyVariation

type OptimizelyVariation struct {
	ID             string                        `json:"id"`
	Key            string                        `json:"key"`
	FeatureEnabled bool                          `json:"featureEnabled"`
	VariablesMap   map[string]OptimizelyVariable `json:"variablesMap"`
}

OptimizelyVariation has variation info

type OptionFunc

type OptionFunc func(*PollingProjectConfigManager)

OptionFunc is used to provide custom configuration to the PollingProjectConfigManager.

func WithDatafileAccessToken added in v1.3.0

func WithDatafileAccessToken(datafileAccessToken string) OptionFunc

WithDatafileAccessToken is an optional function, sets a passed datafile access token

func WithDatafileURLTemplate

func WithDatafileURLTemplate(datafileTemplate string) OptionFunc

WithDatafileURLTemplate is an optional function, sets a passed datafile URL template

func WithInitialDatafile

func WithInitialDatafile(datafile []byte) OptionFunc

WithInitialDatafile is an optional function, sets a passed datafile

func WithPollingInterval

func WithPollingInterval(interval time.Duration) OptionFunc

WithPollingInterval is an optional function, sets a passed polling interval

func WithRequester

func WithRequester(requester utils.Requester) OptionFunc

WithRequester is an optional function, sets a passed requester

type PollingProjectConfigManager

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

PollingProjectConfigManager maintains a dynamic copy of the project config by continuously polling for the datafile from the Optimizely CDN at a given (configurable) interval.

func NewAsyncPollingProjectConfigManager added in v1.1.0

func NewAsyncPollingProjectConfigManager(sdkKey string, pollingMangerOptions ...OptionFunc) *PollingProjectConfigManager

NewAsyncPollingProjectConfigManager returns an instance of the async polling config manager with the customized configuration

func NewPollingProjectConfigManager

func NewPollingProjectConfigManager(sdkKey string, pollingMangerOptions ...OptionFunc) *PollingProjectConfigManager

NewPollingProjectConfigManager returns an instance of the polling config manager with the customized configuration

func (*PollingProjectConfigManager) GetConfig

func (cm *PollingProjectConfigManager) GetConfig() (ProjectConfig, error)

GetConfig returns the project config

func (*PollingProjectConfigManager) GetOptimizelyConfig

func (cm *PollingProjectConfigManager) GetOptimizelyConfig() *OptimizelyConfig

GetOptimizelyConfig returns the optimizely project config

func (*PollingProjectConfigManager) OnProjectConfigUpdate

func (cm *PollingProjectConfigManager) OnProjectConfigUpdate(callback func(notification.ProjectConfigUpdateNotification)) (int, error)

OnProjectConfigUpdate registers a handler for ProjectConfigUpdate notifications

func (*PollingProjectConfigManager) RemoveOnProjectConfigUpdate

func (cm *PollingProjectConfigManager) RemoveOnProjectConfigUpdate(id int) error

RemoveOnProjectConfigUpdate removes handler for ProjectConfigUpdate notification with given id

func (*PollingProjectConfigManager) Start

Start starts the polling

func (*PollingProjectConfigManager) SyncConfig

func (cm *PollingProjectConfigManager) SyncConfig()

SyncConfig downloads datafile and updates projectConfig

type ProjectConfig

type ProjectConfig interface {
	GetAccountID() string
	GetAnonymizeIP() bool
	GetAttributeID(id string) string // returns "" if there is no id
	GetAttributeByKey(key string) (entities.Attribute, error)
	GetAudienceByID(string) (entities.Audience, error)
	GetAudienceMap() map[string]entities.Audience
	GetBotFiltering() bool
	GetEventByKey(string) (entities.Event, error)
	GetExperimentByKey(string) (entities.Experiment, error)
	GetFeatureByKey(string) (entities.Feature, error)
	GetVariableByKey(featureKey string, variableKey string) (entities.Variable, error)
	GetExperimentList() []entities.Experiment
	GetFeatureList() []entities.Feature
	GetGroupByID(string) (entities.Group, error)
	GetProjectID() string
	GetRevision() string
}

ProjectConfig represents the project's experiments and feature flags and contains methods for accessing the them.

type ProjectConfigManager

type ProjectConfigManager interface {
	GetConfig() (ProjectConfig, error)
	GetOptimizelyConfig() *OptimizelyConfig
	RemoveOnProjectConfigUpdate(id int) error
	OnProjectConfigUpdate(callback func(notification.ProjectConfigUpdateNotification)) (int, error)
}

ProjectConfigManager maintains an instance of the ProjectConfig

type StaticProjectConfigManager

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

StaticProjectConfigManager maintains a static copy of the project config

func NewStaticProjectConfigManager

func NewStaticProjectConfigManager(sdkKey string, configMangerOptions ...OptionFunc) *StaticProjectConfigManager

NewStaticProjectConfigManager creates a new instance of the manager with the given sdk key and some options

func (*StaticProjectConfigManager) GetConfig

func (cm *StaticProjectConfigManager) GetConfig() (ProjectConfig, error)

GetConfig returns the project config

func (*StaticProjectConfigManager) GetOptimizelyConfig

func (cm *StaticProjectConfigManager) GetOptimizelyConfig() *OptimizelyConfig

GetOptimizelyConfig returns the optimizely project config

func (*StaticProjectConfigManager) OnProjectConfigUpdate

func (cm *StaticProjectConfigManager) OnProjectConfigUpdate(callback func(notification.ProjectConfigUpdateNotification)) (int, error)

OnProjectConfigUpdate here satisfies interface

func (*StaticProjectConfigManager) RemoveOnProjectConfigUpdate

func (cm *StaticProjectConfigManager) RemoveOnProjectConfigUpdate(id int) error

RemoveOnProjectConfigUpdate here satisfies interface

Directories

Path Synopsis
Package datafileprojectconfig // Package datafileprojectconfig //
Package datafileprojectconfig // Package datafileprojectconfig //
entities
Package entities has entity definitions
Package entities has entity definitions
mappers
Package mappers ...
Package mappers ...

Jump to

Keyboard shortcuts

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