Documentation ¶
Index ¶
- Constants
- Variables
- func BoolPtr(val bool) *bool
- func BuildSSEClient(options options.Options) (*sse.Client, error)
- func Int64Ptr(val int64) *int64
- func IntPtr(val int) *int
- func StartSSEConnection(client *sse.Client, apiConfigStore *APIConfigStore)
- func StringPtr(val string) *string
- type APIConfigStore
- func (cs *APIConfigStore) GetConfig(key string) (*prefabProto.Config, bool)
- func (cs *APIConfigStore) GetContextValue(propertyName string) (interface{}, bool)
- func (cs *APIConfigStore) GetProjectEnvID() int64
- func (cs *APIConfigStore) Len() int
- func (cs *APIConfigStore) SetConfigs(configs []*prefabProto.Config, envID int64)
- func (cs *APIConfigStore) SetFromConfigsProto(configs *prefabProto.Configs)
- type CompositeConfigStore
- type ConditionMatch
- type ConfigEvaluator
- type ConfigMatch
- type ConfigResolver
- type ConfigRuleEvaluator
- func (cve *ConfigRuleEvaluator) EvaluateConditionalValue(conditionalValue *prefabProto.ConditionalValue, contextSet ContextValueGetter) (*prefabProto.ConfigValue, bool)
- func (cve *ConfigRuleEvaluator) EvaluateConfig(config *prefabProto.Config, contextSet ContextValueGetter) ConditionMatch
- func (cve *ConfigRuleEvaluator) EvaluateCriterion(criterion *prefabProto.Criterion, contextSet ContextValueGetter) bool
- func (cve *ConfigRuleEvaluator) EvaluateRow(row *prefabProto.ConfigRow, contextSet ContextValueGetter, rowIndex int) ConditionMatch
- type ConfigStoreGetter
- type ContextValueGetter
- type Decrypter
- type Encryption
- type EnvLookup
- type HTTPClient
- type Hasher
- type Hashing
- type LocalConfigStore
- type LocalConfigYamlParser
- type ProjectEnvIDSupplier
- type Randomer
- type RealEnvLookup
- type WeightedValueResolver
- type WeightedValueResolverIF
Constants ¶
View Source
const ClientVersionHeader = "prefab-cloud-go-" + Version
View Source
const Version = "0.1.0"
Variables ¶
View Source
var ( ErrConfigDoesNotExist = errors.New("config does not exist") ErrEnvVarNotExist = errors.New("environment variable does not exist") ErrTypeCoercionFailed = errors.New("type coercion failed on value from environment variable") )
View Source
var ErrInvalidValueFormat = errors.New("invalid value format")
Functions ¶
func StartSSEConnection ¶
func StartSSEConnection(client *sse.Client, apiConfigStore *APIConfigStore)
Types ¶
type APIConfigStore ¶
type APIConfigStore struct { sync.RWMutex Initialized bool // contains filtered or unexported fields }
func BuildAPIConfigStore ¶
func BuildAPIConfigStore() *APIConfigStore
func (*APIConfigStore) GetConfig ¶
func (cs *APIConfigStore) GetConfig(key string) (*prefabProto.Config, bool)
GetConfig retrieves a Config associated with the given key. It returns a pointer to the Config and a boolean value. The Config pointer is nil if the key does not exist in the store. The boolean value is true if the key exists, and false otherwise.
func (*APIConfigStore) GetContextValue ¶
func (cs *APIConfigStore) GetContextValue(propertyName string) (interface{}, bool)
func (*APIConfigStore) GetProjectEnvID ¶
func (cs *APIConfigStore) GetProjectEnvID() int64
func (*APIConfigStore) Len ¶
func (cs *APIConfigStore) Len() int
func (*APIConfigStore) SetConfigs ¶
func (cs *APIConfigStore) SetConfigs(configs []*prefabProto.Config, envID int64)
func (*APIConfigStore) SetFromConfigsProto ¶
func (cs *APIConfigStore) SetFromConfigsProto(configs *prefabProto.Configs)
type CompositeConfigStore ¶
type CompositeConfigStore struct {
// contains filtered or unexported fields
}
CompositeConfigStore is a config store that composes multiple config stores. It attempts to find a config by key in each store in the order they were provided. The first store that contains the requested config is used, and the search stops. If no store contains the requested config, the CompositeConfigStore returns false to indicate that the config does not exist.
func BuildCompositeConfigStore ¶
func BuildCompositeConfigStore(stores ...ConfigStoreGetter) *CompositeConfigStore
func (*CompositeConfigStore) GetConfig ¶
func (s *CompositeConfigStore) GetConfig(key string) (*prefabProto.Config, bool)
type ConditionMatch ¶
type ConditionMatch struct { Match *prefabProto.ConfigValue SelectedConditionalValue *prefabProto.ConditionalValue RowIndex int ConditionalValueIndex int IsMatch bool }
type ConfigEvaluator ¶
type ConfigEvaluator interface {
EvaluateConfig(config *prefabProto.Config, contextSet ContextValueGetter) (match ConditionMatch)
}
type ConfigMatch ¶
type ConfigMatch struct { OriginalMatch *prefabProto.ConfigValue Match *prefabProto.ConfigValue WeightedValueIndex *int SelectedConditionalValue *prefabProto.ConditionalValue OriginalKey string RowIndex int ConditionalValueIndex int IsMatch bool }
func NewConfigMatchFromConditionMatch ¶
func NewConfigMatchFromConditionMatch(conditionMatch ConditionMatch) ConfigMatch
type ConfigResolver ¶
type ConfigResolver struct { ConfigStore ConfigStoreGetter RuleEvaluator ConfigEvaluator WeightedValueResolver WeightedValueResolverIF Decrypter Decrypter EnvLookup EnvLookup ContextGetter ContextValueGetter }
func NewConfigResolver ¶
func NewConfigResolver(configStore ConfigStoreGetter, supplier ProjectEnvIDSupplier, apiContextGetter ContextValueGetter) *ConfigResolver
func (ConfigResolver) ResolveValue ¶
func (c ConfigResolver) ResolveValue(key string, contextSet ContextValueGetter) (ConfigMatch, error)
type ConfigRuleEvaluator ¶
type ConfigRuleEvaluator struct {
// contains filtered or unexported fields
}
func NewConfigRuleEvaluator ¶
func NewConfigRuleEvaluator(configStore ConfigStoreGetter, supplier ProjectEnvIDSupplier) *ConfigRuleEvaluator
func (*ConfigRuleEvaluator) EvaluateConditionalValue ¶
func (cve *ConfigRuleEvaluator) EvaluateConditionalValue(conditionalValue *prefabProto.ConditionalValue, contextSet ContextValueGetter) (*prefabProto.ConfigValue, bool)
func (*ConfigRuleEvaluator) EvaluateConfig ¶
func (cve *ConfigRuleEvaluator) EvaluateConfig(config *prefabProto.Config, contextSet ContextValueGetter) ConditionMatch
func (*ConfigRuleEvaluator) EvaluateCriterion ¶
func (cve *ConfigRuleEvaluator) EvaluateCriterion(criterion *prefabProto.Criterion, contextSet ContextValueGetter) bool
func (*ConfigRuleEvaluator) EvaluateRow ¶
func (cve *ConfigRuleEvaluator) EvaluateRow(row *prefabProto.ConfigRow, contextSet ContextValueGetter, rowIndex int) ConditionMatch
type ConfigStoreGetter ¶
type ConfigStoreGetter interface {
GetConfig(key string) (config *prefabProto.Config, exists bool)
}
type ContextValueGetter ¶
type Encryption ¶
type Encryption struct{}
func (*Encryption) DecryptValue ¶
func (d *Encryption) DecryptValue(secretKeyString string, value string) (string, error)
type HTTPClient ¶
func BuildHTTPClient ¶
func BuildHTTPClient(options options.Options) (*HTTPClient, error)
func (*HTTPClient) Load ¶
func (c *HTTPClient) Load(offset int32) (*prefabProto.Configs, error)
func (*HTTPClient) LoadFromURI ¶
func (c *HTTPClient) LoadFromURI(uri string, apiKey string, offset int32) (*prefabProto.Configs, error)
type LocalConfigStore ¶
type LocalConfigStore struct { Initialized bool // contains filtered or unexported fields }
func NewLocalConfigStore ¶
func NewLocalConfigStore(sourceDirectory string, options *options.Options) *LocalConfigStore
func (*LocalConfigStore) GetConfig ¶
func (s *LocalConfigStore) GetConfig(key string) (*prefabProto.Config, bool)
type LocalConfigYamlParser ¶
type LocalConfigYamlParser struct{}
func (*LocalConfigYamlParser) Parse ¶
func (p *LocalConfigYamlParser) Parse(yamlData []byte) ([]*prefabProto.Config, error)
type ProjectEnvIDSupplier ¶
type ProjectEnvIDSupplier interface {
GetProjectEnvID() int64
}
type RealEnvLookup ¶
type RealEnvLookup struct{}
type WeightedValueResolver ¶
func NewWeightedValueResolver ¶
func NewWeightedValueResolver(seed int64, hasher Hasher) *WeightedValueResolver
func (*WeightedValueResolver) Resolve ¶
func (wve *WeightedValueResolver) Resolve(weightedValues *prefabProto.WeightedValues, propertyName string, contextGetter ContextValueGetter) (*prefabProto.ConfigValue, int)
type WeightedValueResolverIF ¶
type WeightedValueResolverIF interface {
Resolve(weightedValues *prefabProto.WeightedValues, propertyName string, contextGetter ContextValueGetter) (valueResult *prefabProto.ConfigValue, index int)
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.