Documentation ¶
Index ¶
- Constants
- Variables
- func BoolPtr(val bool) *bool
- func Int64Ptr(val int64) *int64
- func IntPtr(val int) *int
- func StringPtr(val string) *string
- func Uint32Ptr(val uint32) *uint32
- type ConditionMatch
- type ConfigEvaluator
- type ConfigMatch
- type ConfigParser
- 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 LocalConfigJSONParser
- 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.2.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 ¶
Types ¶
type ConditionMatch ¶
type ConditionMatch struct { Match *prefabProto.ConfigValue RowIndex *int ConditionalValueIndex *int IsMatch bool }
type ConfigEvaluator ¶
type ConfigEvaluator interface {
EvaluateConfig(config *prefabProto.Config, contextSet ContextValueGetter) (match ConditionMatch)
}
type ConfigMatch ¶
type ConfigMatch struct { ConfigID int64 ConfigType prefabProto.ConfigType OriginalMatch *prefabProto.ConfigValue Match *prefabProto.ConfigValue ConfigKey string WeightedValueIndex *int RowIndex *int ConditionalValueIndex *int IsMatch bool }
func NewConfigMatchFromConditionMatch ¶
func NewConfigMatchFromConditionMatch(conditionMatch ConditionMatch) ConfigMatch
type ConfigParser ¶ added in v0.0.7
type ConfigParser interface {
Parse(data []byte) ([]*prefabProto.Config, int64, error)
}
type ConfigResolver ¶
type ConfigResolver struct { ConfigStore ConfigStoreGetter RuleEvaluator ConfigEvaluator WeightedValueResolver WeightedValueResolverIF Decrypter Decrypter EnvLookup EnvLookup ContextGetter ContextValueGetter }
func NewConfigResolver ¶
func NewConfigResolver(configStore ConfigStoreGetter) *ConfigResolver
func (ConfigResolver) Keys ¶ added in v0.0.4
func (c ConfigResolver) Keys() []string
func (ConfigResolver) ResolveValue ¶
func (c ConfigResolver) ResolveValue(key string, contextSet ContextValueGetter) (ConfigMatch, error)
func (ConfigResolver) ResolveValueForConfig ¶ added in v0.0.4
func (c ConfigResolver) ResolveValueForConfig(config *prefabProto.Config, contextSet ContextValueGetter, key string) (ConfigMatch, error)
type ConfigRuleEvaluator ¶
type ConfigRuleEvaluator struct {
// contains filtered or unexported fields
}
func NewConfigRuleEvaluator ¶
func NewConfigRuleEvaluator(configStore ConfigStoreGetter, projectEnvIDSupplier 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) Keys() []string ContextValueGetter ProjectEnvIDSupplier }
TODO: add a `freshen` or similar method
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 int64) (*prefabProto.Configs, error)
func (*HTTPClient) LoadFromURI ¶
func (c *HTTPClient) LoadFromURI(uri string, apiKey string, offset int64) (*prefabProto.Configs, error)
type LocalConfigJSONParser ¶ added in v0.0.7
type LocalConfigJSONParser struct{}
func (*LocalConfigJSONParser) Parse ¶ added in v0.0.7
func (p *LocalConfigJSONParser) Parse(jsonData []byte) ([]*prefabProto.Config, int64, error)
type LocalConfigYamlParser ¶
type LocalConfigYamlParser struct{}
func (*LocalConfigYamlParser) Parse ¶
func (p *LocalConfigYamlParser) Parse(yamlData []byte) ([]*prefabProto.Config, int64, 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.