Documentation
¶
Overview ¶
Package config //
Package config //
Package config //
Package config //
Index ¶
- Constants
- Variables
- type EyeofcloudAttribute
- type EyeofcloudAudience
- type EyeofcloudConfig
- type EyeofcloudEvent
- type EyeofcloudExperiment
- type EyeofcloudFeature
- type EyeofcloudVariable
- type EyeofcloudVariation
- type OptionFunc
- func WithDatafileAccessToken(datafileAccessToken string) OptionFunc
- func WithDatafileURLTemplate(datafileTemplate string) OptionFunc
- func WithInitialDatafile(datafile []byte) OptionFunc
- func WithPollingInterval(interval time.Duration) OptionFunc
- func WithRequester(requester utils.Requester) OptionFunc
- type PollingProjectConfigManager
- func (cm *PollingProjectConfigManager) GetConfig() (ProjectConfig, error)
- func (cm *PollingProjectConfigManager) GetEyeofcloudConfig() *EyeofcloudConfig
- func (cm *PollingProjectConfigManager) OnProjectConfigUpdate(callback func(notification.ProjectConfigUpdateNotification)) (int, error)
- func (cm *PollingProjectConfigManager) RemoveOnProjectConfigUpdate(id int) error
- func (cm *PollingProjectConfigManager) Start(ctx context.Context)
- func (cm *PollingProjectConfigManager) SyncConfig()
- type ProjectConfig
- type ProjectConfigManager
- type StaticProjectConfigManager
- func NewStaticProjectConfigManager(config ProjectConfig, logger logging.EyeofcloudLogProducer) *StaticProjectConfigManager
- func NewStaticProjectConfigManagerFromPayload(payload []byte, logger logging.EyeofcloudLogProducer) (*StaticProjectConfigManager, error)
- func NewStaticProjectConfigManagerFromURL(sdkKey string) (*StaticProjectConfigManager, error)
- func NewStaticProjectConfigManagerWithOptions(sdkKey string, configMangerOptions ...OptionFunc) *StaticProjectConfigManager
- func (cm *StaticProjectConfigManager) GetConfig() (ProjectConfig, error)
- func (cm *StaticProjectConfigManager) GetEyeofcloudConfig() *EyeofcloudConfig
- func (cm *StaticProjectConfigManager) OnProjectConfigUpdate(callback func(notification.ProjectConfigUpdateNotification)) (int, error)
- func (cm *StaticProjectConfigManager) RemoveOnProjectConfigUpdate(id int) error
Constants ¶
const AuthDatafileURLTemplate = "https://config.eyeofcloud.com/datafiles/auth/%s.json"
AuthDatafileURLTemplate is used to construct the endpoint for retrieving authenticated datafile from the CDN
const DatafileURLTemplate = "https://cdn.eyeofcloud.com/datafiles/%s.json"
DatafileURLTemplate is used to construct the endpoint for retrieving regular datafile from the CDN
const DefaultPollingInterval = 5 * time.Minute // default to 5 minutes for polling
DefaultPollingInterval sets default interval for polling manager
const LastModified = "Last-Modified"
LastModified header key for response
const ModifiedSince = "If-Modified-Since"
ModifiedSince header key for request
Variables ¶
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 EyeofcloudAttribute ¶
EyeofcloudAttribute has attribute info
type EyeofcloudAudience ¶
type EyeofcloudAudience struct {
ID string `json:"id"`
Name string `json:"name"`
Conditions string `json:"conditions"`
}
EyeofcloudAudience has audience info
type EyeofcloudConfig ¶
type EyeofcloudConfig struct {
EnvironmentKey string `json:"environmentKey"`
SdkKey string `json:"sdkKey"`
Revision string `json:"revision"`
// This experimentsMap is for experiments of legacy projects only.
// For flag projects, experiment keys are not guaranteed to be unique
// across multiple flags, so this map may not include all experiments
// when keys conflict.
ExperimentsMap map[string]EyeofcloudExperiment `json:"experimentsMap"`
FeaturesMap map[string]EyeofcloudFeature `json:"featuresMap"`
Attributes []EyeofcloudAttribute `json:"attributes"`
Audiences []EyeofcloudAudience `json:"audiences"`
Events []EyeofcloudEvent `json:"events"`
// contains filtered or unexported fields
}
EyeofcloudConfig is a snapshot of the experiments and features in the project config
func NewEyeofcloudConfig ¶
func NewEyeofcloudConfig(projConfig ProjectConfig) *EyeofcloudConfig
NewEyeofcloudConfig constructs EyeofcloudConfig object
func (EyeofcloudConfig) GetDatafile ¶
func (c EyeofcloudConfig) GetDatafile() string
GetDatafile returns a string representation of the environment's datafile
type EyeofcloudEvent ¶
type EyeofcloudEvent struct {
ID string `json:"id"`
Key string `json:"key"`
ExperimentIds []string `json:"experimentIds"`
}
EyeofcloudEvent has event info
type EyeofcloudExperiment ¶
type EyeofcloudExperiment struct {
ID string `json:"id"`
Key string `json:"key"`
Audiences string `json:"audiences"`
VariationsMap map[string]EyeofcloudVariation `json:"variationsMap"`
}
EyeofcloudExperiment has experiment info
type EyeofcloudFeature ¶
type EyeofcloudFeature struct {
ID string `json:"id"`
Key string `json:"key"`
ExperimentRules []EyeofcloudExperiment `json:"experimentRules"`
DeliveryRules []EyeofcloudExperiment `json:"deliveryRules"`
VariablesMap map[string]EyeofcloudVariable `json:"variablesMap"`
// Deprecated: Use experimentRules and deliveryRules
ExperimentsMap map[string]EyeofcloudExperiment `json:"experimentsMap"`
}
EyeofcloudFeature has feature info
type EyeofcloudVariable ¶
type EyeofcloudVariable struct {
ID string `json:"id"`
Key string `json:"key"`
Type string `json:"type"`
Value string `json:"value"`
}
EyeofcloudVariable has variable info
type EyeofcloudVariation ¶
type EyeofcloudVariation struct {
ID string `json:"id"`
Key string `json:"key"`
FeatureEnabled bool `json:"featureEnabled"`
VariablesMap map[string]EyeofcloudVariable `json:"variablesMap"`
}
EyeofcloudVariation has variation info
type OptionFunc ¶
type OptionFunc func(*PollingProjectConfigManager)
OptionFunc is used to provide custom configuration to the PollingProjectConfigManager.
func WithDatafileAccessToken ¶
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 Eyeofcloud CDN at a given (configurable) interval.
func NewAsyncPollingProjectConfigManager ¶
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) GetEyeofcloudConfig ¶
func (cm *PollingProjectConfigManager) GetEyeofcloudConfig() *EyeofcloudConfig
GetEyeofcloudConfig returns the eyeofcloud 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 ¶
func (cm *PollingProjectConfigManager) Start(ctx context.Context)
Start starts the polling
func (*PollingProjectConfigManager) SyncConfig ¶
func (cm *PollingProjectConfigManager) SyncConfig()
SyncConfig downloads datafile and updates projectConfig
type ProjectConfig ¶
type ProjectConfig interface {
GetDatafile() string
GetHostForODP() string
GetPublicKeyForODP() string
GetAccountID() string
GetAnonymizeIP() bool
GetAttributeID(id string) string // returns "" if there is no id
GetAttributeByKey(key string) (entities.Attribute, error)
GetAudienceList() (audienceList []entities.Audience)
GetAudienceByID(string) (entities.Audience, error)
GetAudienceMap() map[string]entities.Audience
GetBotFiltering() bool
GetEvents() []entities.Event
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
GetSegmentList() []string
GetIntegrationList() []entities.Integration
GetRolloutList() (rolloutList []entities.Rollout)
GetFeatureList() []entities.Feature
GetGroupByID(string) (entities.Group, error)
GetProjectID() string
GetRevision() string
SendFlagDecisions() bool
GetSdkKey() string
GetEnvironmentKey() string
GetAttributes() []entities.Attribute
GetFlagVariationsMap() map[string][]entities.Variation
}
ProjectConfig represents the project's experiments and feature flags and contains methods for accessing the them.
type ProjectConfigManager ¶
type ProjectConfigManager interface {
GetConfig() (ProjectConfig, error)
GetEyeofcloudConfig() *EyeofcloudConfig
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(config ProjectConfig, logger logging.EyeofcloudLogProducer) *StaticProjectConfigManager
NewStaticProjectConfigManager creates a new instance of the manager with the given project config
func NewStaticProjectConfigManagerFromPayload ¶
func NewStaticProjectConfigManagerFromPayload(payload []byte, logger logging.EyeofcloudLogProducer) (*StaticProjectConfigManager, error)
NewStaticProjectConfigManagerFromPayload returns new instance of StaticProjectConfigManager for payload
func NewStaticProjectConfigManagerFromURL ¶
func NewStaticProjectConfigManagerFromURL(sdkKey string) (*StaticProjectConfigManager, error)
NewStaticProjectConfigManagerFromURL returns new instance of StaticProjectConfigManager for URL
func NewStaticProjectConfigManagerWithOptions ¶
func NewStaticProjectConfigManagerWithOptions(sdkKey string, configMangerOptions ...OptionFunc) *StaticProjectConfigManager
NewStaticProjectConfigManagerWithOptions 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) GetEyeofcloudConfig ¶
func (cm *StaticProjectConfigManager) GetEyeofcloudConfig() *EyeofcloudConfig
GetEyeofcloudConfig returns the eyeofcloud 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