models

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExtractConfigurationsFromPersistentCache = ExtractConfigurationsFromAPIResponse

AliasFunction : Only for readability purpose. The configurations stored in Persistent cache & configuration fetched from API both are in same format

Functions

func ExtractConfigurationsFromAPIResponse added in v0.5.0

func ExtractConfigurationsFromAPIResponse(res []byte) []byte

ExtractConfigurationsFromAPIResponse will 1. Parse the configuration into models.APIConfig struct 2. Extract all the Features, Properties & Segments into models.Configurations struct

func ExtractConfigurationsFromBootstrapJson added in v0.5.0

func ExtractConfigurationsFromBootstrapJson(bootstrapFileData []byte, collectionId, environmentId string) []byte

ExtractConfigurationsFromBootstrapJson will 1. Parse the bootstrap configuration into models.BootstrapConfig struct 2. Extract all the Features, Properties & Segments that are under environmentId and assigned to collectionId into models.Configurations struct 3. And Marshals the models.Configurations Currently, for any type of errors that will occur, this method will not return error instead returns a nil. In the future, we will consider returning the error.

func FormatConfig added in v0.5.0

func FormatConfig(data []byte, environmentId string) []byte

FormatConfig : will reformat the configurations from type Configurations to type APIConfig

func GetNormalizedValue added in v0.5.0

func GetNormalizedValue(str string) int

func IsValidDataType added in v0.2.0

func IsValidDataType(category string) bool

func SetCache

func SetCache(featureMap map[string]Feature, propertyMap map[string]Property, segmentMap map[string]Segment)

SetCache : Set Cache

Types

type APIConfig added in v0.5.0

type APIConfig struct {
	Environments []Environment `json:"environments"`
	Segments     []Segment     `json:"segments"`
}

APIConfig : the format of configurations returned from the API: `GET /config?action=sdkConfig`

type BootstrapConfig added in v0.5.0

type BootstrapConfig struct {
	Environments []EnvironmentC `json:"environments"`
	Collections  []Collection   `json:"collections"`
	Segments     []Segment      `json:"segments"`
}

BootstrapConfig : the format of bootstrap configurations.

type Cache

type Cache struct {
	FeatureMap       map[string]Feature
	PropertyMap      map[string]Property
	SegmentMap       map[string]Segment
	SecretManagerMap map[string]interface{}
}

Cache : Cache struct

var CacheInstance *Cache

CacheInstance : Cache Instance

func GetCacheInstance

func GetCacheInstance() *Cache

GetCacheInstance : Get Cache Instance

type Collection

type Collection struct {
	Name         string `json:"name"`
	CollectionID string `json:"collection_id"`
}

type Configurations added in v0.5.0

type Configurations struct {
	Features   []Feature  `json:"features"`
	Properties []Property `json:"properties"`
	Segments   []Segment  `json:"segments"`
}

Configurations : all the configurations pulled out from bootstrapJson/persistentCache/GitConfig/APIResponse will be stored in this struct format.

type Environment added in v0.5.0

type Environment struct {
	Name          string     `json:"name"`
	EnvironmentID string     `json:"environment_id"`
	Features      []Feature  `json:"features"`
	Properties    []Property `json:"properties"`
}

type EnvironmentC added in v0.5.0

type EnvironmentC struct {
	Name          string      `json:"name"`
	EnvironmentID string      `json:"environment_id"`
	Features      []FeatureC  `json:"features"`
	Properties    []PropertyC `json:"properties"`
}

type Feature

type Feature struct {
	Name              string        `json:"name"`
	FeatureID         string        `json:"feature_id"`
	DataType          string        `json:"type"`
	Format            string        `json:"format"`
	EnabledValue      interface{}   `json:"enabled_value"`
	DisabledValue     interface{}   `json:"disabled_value"`
	SegmentRules      []SegmentRule `json:"segment_rules"`
	Enabled           bool          `json:"enabled"`
	RolloutPercentage *int          `json:"rollout_percentage"`
}

Feature : Feature struct

func (*Feature) GetCurrentValue

func (f *Feature) GetCurrentValue(entityID string, entityAttributes ...map[string]interface{}) interface{}

GetCurrentValue returns one of the Enabled/Disabled/Overridden value based on the evaluation.

The function takes in entityId & entityAttributes parameters.

entityId is a string identifier related to the Entity against which the feature will be evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App Configuration, it must provide a unique entity ID.

entityAttributes is a map of type `map[string]interface{}` consisting of the attribute name and their values that defines the specified entity. This is an optional parameter if the feature flag is not configured with any targeting definition. If the targeting is configured, then entityAttributes should be provided for the rule evaluation. An attribute is a parameter that is used to define a segment. The SDK uses the attribute values to determine if the specified entity satisfies the targeting rules, and returns the appropriate feature flag value.

func (*Feature) GetDisabledValue

func (f *Feature) GetDisabledValue() interface{}

GetDisabledValue : Get Disabled Value

func (*Feature) GetEnabledValue

func (f *Feature) GetEnabledValue() interface{}

GetEnabledValue : Get Enabled Value

func (*Feature) GetFeatureDataFormat added in v0.2.0

func (f *Feature) GetFeatureDataFormat() string

GetFeatureDataFormat : Get Feature Data Format

func (*Feature) GetFeatureDataType

func (f *Feature) GetFeatureDataType() string

GetFeatureDataType : Get Feature Data Type

func (*Feature) GetFeatureID added in v0.1.1

func (f *Feature) GetFeatureID() string

GetFeatureID : Get Feature ID

func (*Feature) GetFeatureName

func (f *Feature) GetFeatureName() string

GetFeatureName : Get Feature Name

func (*Feature) GetRolloutPercentage added in v0.3.0

func (f *Feature) GetRolloutPercentage() int

GetRolloutPercentage : Get the Feature flag rollout percentage

func (*Feature) GetSegmentRules

func (f *Feature) GetSegmentRules() []SegmentRule

GetSegmentRules : Get Segment Rules

func (*Feature) IsEnabled

func (f *Feature) IsEnabled() bool

IsEnabled returns the state of the feature flag. Returns true, if the feature flag is enabled, otherwise returns false.

type FeatureC added in v0.5.0

type FeatureC struct {
	Feature
	Collections []Collection `json:"collections"`
}

type Property

type Property struct {
	Name         string        `json:"name"`
	PropertyID   string        `json:"property_id"`
	DataType     string        `json:"type"`
	Format       string        `json:"format"`
	Value        interface{}   `json:"value"`
	SegmentRules []SegmentRule `json:"segment_rules"`
}

Property : Property struct

func (*Property) GetCurrentValue

func (p *Property) GetCurrentValue(entityID string, entityAttributes ...map[string]interface{}) interface{}

GetCurrentValue returns the default property value or its overridden value based on the evaluation.

The function takes in entityId & entityAttributes parameters.

entityId is a string identifier related to the Entity against which the property will be evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App Configuration, it must provide a unique entity ID.

entityAttributes is a map of type `map[string]interface{}` consisting of the attribute name and their values that defines the specified entity. This is an optional parameter if the property is not configured with any targeting definition. If the targeting is configured, then entityAttributes should be provided for the rule evaluation. An attribute is a parameter that is used to define a segment. The SDK uses the attribute values to determine if the specified entity satisfies the targeting rules, and returns the appropriate property value.

func (*Property) GetPropertyDataFormat added in v0.2.0

func (p *Property) GetPropertyDataFormat() string

GetPropertyDataFormat : Get Property Data Format

func (*Property) GetPropertyDataType

func (p *Property) GetPropertyDataType() string

GetPropertyDataType : Get Property Data Type

func (*Property) GetPropertyID added in v0.1.1

func (p *Property) GetPropertyID() string

GetPropertyID : Get Property Id

func (*Property) GetPropertyName

func (p *Property) GetPropertyName() string

GetPropertyName : Get Property Name

func (*Property) GetSegmentRules

func (p *Property) GetSegmentRules() []SegmentRule

GetSegmentRules : Get Segment Rules

func (*Property) GetValue

func (p *Property) GetValue() interface{}

GetValue : Get Value

type PropertyC added in v0.5.0

type PropertyC struct {
	Property
	Collections []Collection `json:"collections"`
}

type Rule

type Rule struct {
	Values        []interface{} `json:"values"`
	Operator      string        `json:"operator"`
	AttributeName string        `json:"attribute_name"`
}

Rule : Rule struct

func (*Rule) EvaluateRule

func (r *Rule) EvaluateRule(entityAttributes map[string]interface{}) bool

EvaluateRule : Evaluate Rule

func (*Rule) GetAttributeName

func (r *Rule) GetAttributeName() string

GetAttributeName : Get Attribute Name

func (*Rule) GetOperator

func (r *Rule) GetOperator() string

GetOperator : Get Operator

func (*Rule) GetValues

func (r *Rule) GetValues() []interface{}

GetValues : Get Values

type RuleElem

type RuleElem struct {
	Segments []string `json:"segments"`
}

RuleElem : RuleElem struct

type SecretProperty added in v0.3.1

type SecretProperty struct {
	PropertyID string
}

SecretProperty : SecretProperty struct

func (*SecretProperty) GetCurrentValue added in v0.3.1

func (sp *SecretProperty) GetCurrentValue(entityID string, entityAttributes ...map[string]interface{}) (result sm.SecretIntf, response *core.DetailedResponse, err error)

GetCurrentValue returns the actual secret value(default or overridden) based on the evaluation.

The function takes in entityId & entityAttributes parameters.

entityId is a string identifier related to the Entity against which the property will be evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App Configuration, it must provide a unique entity ID.

entityAttributes is a map of type `map[string]interface{}` consisting of the attribute name and their values that defines the specified entity. This is an optional parameter if the property is not configured with any targeting definition. If the targeting is configured, then entityAttributes should be provided for the rule evaluation.

type Segment

type Segment struct {
	Name      string `json:"name"`
	SegmentID string `json:"segment_id"`
	Rules     []Rule `json:"rules"`
}

Segment : Segment struct

func (*Segment) EvaluateRule

func (s *Segment) EvaluateRule(entityAttributes map[string]interface{}) bool

EvaluateRule : Evaluate Rule

func (*Segment) GetName

func (s *Segment) GetName() string

GetName : Get Name

func (*Segment) GetRules

func (s *Segment) GetRules() []Rule

GetRules : Get Rules

func (*Segment) GetSegmentID added in v0.1.1

func (s *Segment) GetSegmentID() string

GetSegmentID : Get SegmentID

type SegmentRule

type SegmentRule struct {
	Rules             []RuleElem   `json:"rules"`
	Value             interface{}  `json:"value"`
	Order             int          `json:"order"`
	RolloutPercentage *interface{} `json:"rollout_percentage"`
}

SegmentRule : SegmentRule struct

func (*SegmentRule) GetOrder

func (sr *SegmentRule) GetOrder() int

GetOrder : Get Order

func (*SegmentRule) GetRolloutPercentage added in v0.3.0

func (sr *SegmentRule) GetRolloutPercentage() interface{}

GetRolloutPercentage : Get the rollout percentage of the segment rule

func (*SegmentRule) GetRules

func (sr *SegmentRule) GetRules() []RuleElem

GetRules : Get Rules

func (*SegmentRule) GetValue

func (sr *SegmentRule) GetValue() interface{}

GetValue : Get Value

Jump to

Keyboard shortcuts

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