decision

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Package decision //

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FeatureNotification

func FeatureNotification(featureKey string, featureDecision *FeatureDecision, userContext *entities.UserContext) *notification.DecisionNotification

FeatureNotification constructs default feature notification

func FeatureNotificationWithVariables

func FeatureNotificationWithVariables(featureKey string, featureDecision *FeatureDecision, userContext *entities.UserContext,
	variables map[string]interface{}) *notification.DecisionNotification

FeatureNotificationWithVariables constructs feature notification with variables

func FlagNotification

func FlagNotification(flagKey, variationKey, ruleKey string, enabled, decisionEventDispatched bool, userContext entities.UserContext, variables map[string]interface{}, reasons []string) *notification.DecisionNotification

FlagNotification constructs default flag notification

Types

type CESOptionFunc

type CESOptionFunc func(*CompositeExperimentService)

CESOptionFunc is used to assign optional configuration options

func WithOverrideStore

func WithOverrideStore(overrideStore ExperimentOverrideStore) CESOptionFunc

WithOverrideStore adds an experiment override store

func WithUserProfileService

func WithUserProfileService(userProfileService UserProfileService) CESOptionFunc

WithUserProfileService adds a user profile service

type CSOptionFunc

type CSOptionFunc func(*CompositeService)

CSOptionFunc is used to pass custom config options into the CompositeService.

func WithCompositeExperimentService

func WithCompositeExperimentService(compositeExperimentService ExperimentService) CSOptionFunc

WithCompositeExperimentService sets the composite experiment service on the CompositeService

type CompositeExperimentService

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

CompositeExperimentService bridges together the various experiment decision services that ship by default with the SDK

func NewCompositeExperimentService

func NewCompositeExperimentService(sdkKey string, options ...CESOptionFunc) *CompositeExperimentService

NewCompositeExperimentService creates a new instance of the CompositeExperimentService

func (CompositeExperimentService) GetDecision

func (s CompositeExperimentService) GetDecision(decisionContext ExperimentDecisionContext, userContext entities.UserContext, options *decide.Options) (decision ExperimentDecision, reasons decide.DecisionReasons, err error)

GetDecision returns a decision for the given experiment and user context

type CompositeFeatureService

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

CompositeFeatureService is the default out-of-the-box feature decision service

func NewCompositeFeatureService

func NewCompositeFeatureService(sdkKey string, compositeExperimentService ExperimentService) *CompositeFeatureService

NewCompositeFeatureService returns a new instance of the CompositeFeatureService

func (CompositeFeatureService) GetDecision

GetDecision returns a decision for the given feature and user context

type CompositeService

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

CompositeService is the entry-point into the decision service. It provides out of the box decision making for Features and Experiments.

func NewCompositeService

func NewCompositeService(sdkKey string, options ...CSOptionFunc) *CompositeService

NewCompositeService returns a new instance of the CompositeService with the defaults

func (CompositeService) GetExperimentDecision

func (s CompositeService) GetExperimentDecision(experimentDecisionContext ExperimentDecisionContext, userContext entities.UserContext, options *decide.Options) (experimentDecision ExperimentDecision, reasons decide.DecisionReasons, err error)

GetExperimentDecision returns a decision for the given experiment key

func (CompositeService) GetFeatureDecision

func (s CompositeService) GetFeatureDecision(featureDecisionContext FeatureDecisionContext, userContext entities.UserContext, options *decide.Options) (FeatureDecision, decide.DecisionReasons, error)

GetFeatureDecision returns a decision for the given feature key

func (CompositeService) OnDecision

func (s CompositeService) OnDecision(callback func(notification.DecisionNotification)) (int, error)

OnDecision registers a handler for Decision notifications

func (CompositeService) RemoveOnDecision

func (s CompositeService) RemoveOnDecision(id int) error

RemoveOnDecision removes handler for Decision notification with given id

type Decision

type Decision struct {
	Reason reasons.Reason
}

Decision contains base information about a decision

type ExperimentBucketerService

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

ExperimentBucketerService makes a decision using the experiment bucketer

func NewExperimentBucketerService

func NewExperimentBucketerService(logger logging.OptimizelyLogProducer) *ExperimentBucketerService

NewExperimentBucketerService returns a new instance of the ExperimentBucketerService

func (ExperimentBucketerService) GetDecision

GetDecision returns the decision with the variation the user is bucketed into

type ExperimentDecision

type ExperimentDecision struct {
	Decision
	Variation *entities.Variation
}

ExperimentDecision contains the decision information about an experiment

type ExperimentDecisionContext

type ExperimentDecisionContext struct {
	Experiment    *entities.Experiment
	ProjectConfig config.ProjectConfig
}

ExperimentDecisionContext contains the information needed to be able to make a decision for a given experiment

type ExperimentOverrideKey

type ExperimentOverrideKey struct {
	ExperimentKey, UserID string
}

ExperimentOverrideKey represents the user ID and experiment associated with an override variation

type ExperimentOverrideService

type ExperimentOverrideService struct {
	Overrides ExperimentOverrideStore
	// contains filtered or unexported fields
}

ExperimentOverrideService makes a decision using an ExperimentOverridesStore Implements the ExperimentService interface

func NewExperimentOverrideService

func NewExperimentOverrideService(overrides ExperimentOverrideStore, logger logging.OptimizelyLogProducer) *ExperimentOverrideService

NewExperimentOverrideService returns a pointer to an initialized ExperimentOverrideService

func (ExperimentOverrideService) GetDecision

func (s ExperimentOverrideService) GetDecision(decisionContext ExperimentDecisionContext, userContext entities.UserContext, options *decide.Options) (experimentDecision ExperimentDecision, reasons decide.DecisionReasons, err error)

GetDecision returns a decision with a variation when the store returns a variation assignment for the given user and experiment

type ExperimentOverrideStore

type ExperimentOverrideStore interface {
	// Returns a variation associated with overrideKey
	GetVariation(overrideKey ExperimentOverrideKey) (string, bool)
}

ExperimentOverrideStore provides read access to overrides

type ExperimentService

type ExperimentService interface {
	GetDecision(decisionContext ExperimentDecisionContext, userContext entities.UserContext, options *decide.Options) (ExperimentDecision, decide.DecisionReasons, error)
}

ExperimentService can make a decision about an experiment

type ExperimentWhitelistService

type ExperimentWhitelistService struct{}

ExperimentWhitelistService makes a decision using an experiment's whitelist (a map of user id to variation keys) Implements the ExperimentService interface

func NewExperimentWhitelistService

func NewExperimentWhitelistService() *ExperimentWhitelistService

NewExperimentWhitelistService returns a new instance of ExperimentWhitelistService

func (ExperimentWhitelistService) GetDecision

GetDecision returns a decision with a variation when a variation assignment is found in the experiment whitelist for the given user and experiment

type FeatureDecision

type FeatureDecision struct {
	Decision
	Source     Source
	Experiment entities.Experiment
	Variation  *entities.Variation
}

FeatureDecision contains the decision information about a feature

type FeatureDecisionContext

type FeatureDecisionContext struct {
	Feature               *entities.Feature
	ProjectConfig         config.ProjectConfig
	Variable              entities.Variable
	ForcedDecisionService *ForcedDecisionService
}

FeatureDecisionContext contains the information needed to be able to make a decision for a given feature

type FeatureExperimentService

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

FeatureExperimentService helps evaluate feature test associated with the feature

func NewFeatureExperimentService

func NewFeatureExperimentService(logger logging.OptimizelyLogProducer, compositeExperimentService ExperimentService) *FeatureExperimentService

NewFeatureExperimentService returns a new instance of the FeatureExperimentService

func (FeatureExperimentService) GetDecision

GetDecision returns a decision for the given feature test and user context

type FeatureService

type FeatureService interface {
	GetDecision(decisionContext FeatureDecisionContext, userContext entities.UserContext, options *decide.Options) (FeatureDecision, decide.DecisionReasons, error)
}

FeatureService can make a decision about a Feature Flag (can be feature test or rollout)

type ForcedDecisionService

type ForcedDecisionService struct {
	UserID string
	// contains filtered or unexported fields
}

ForcedDecisionService defines user contexts that the SDK will use to make decisions for.

func NewForcedDecisionService

func NewForcedDecisionService(userID string) *ForcedDecisionService

NewForcedDecisionService returns an instance of the optimizely user context.

func (*ForcedDecisionService) CreateCopy

CreateCopy creates and returns a copy of the forced decision service.

func (*ForcedDecisionService) FindValidatedForcedDecision

func (f *ForcedDecisionService) FindValidatedForcedDecision(projectConfig config.ProjectConfig, context OptimizelyDecisionContext, options *decide.Options) (variation *entities.Variation, reasons decide.DecisionReasons, err error)

FindValidatedForcedDecision returns validated forced decision.

func (*ForcedDecisionService) GetForcedDecision

GetForcedDecision returns the forced decision for a given flag and an optional rule if rule key is empty, forced decision will be returned for the flagKey.

func (*ForcedDecisionService) RemoveAllForcedDecisions

func (f *ForcedDecisionService) RemoveAllForcedDecisions() bool

RemoveAllForcedDecisions removes all forced decisions bound to this user context.

func (*ForcedDecisionService) RemoveForcedDecision

func (f *ForcedDecisionService) RemoveForcedDecision(context OptimizelyDecisionContext) bool

RemoveForcedDecision removes the forced decision for a given flag and an optional rule. if rule key is empty, forced decision will be removed for the flagKey.

func (*ForcedDecisionService) SetForcedDecision

func (f *ForcedDecisionService) SetForcedDecision(context OptimizelyDecisionContext, decision OptimizelyForcedDecision) bool

SetForcedDecision sets the forced decision (variation key) for a given flag and an optional rule. if rule key is empty, forced decision will be mapped against the flagKey. returns true if the forced decision has been set successfully.

type MapExperimentOverridesStore

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

MapExperimentOverridesStore is a map-based implementation of ExperimentOverridesStore that is safe to use concurrently

func NewMapExperimentOverridesStore

func NewMapExperimentOverridesStore() *MapExperimentOverridesStore

NewMapExperimentOverridesStore returns a new MapExperimentOverridesStore

func (*MapExperimentOverridesStore) GetVariation

func (m *MapExperimentOverridesStore) GetVariation(overrideKey ExperimentOverrideKey) (string, bool)

GetVariation returns the override variation key associated with the given user+experiment key

func (*MapExperimentOverridesStore) RemoveVariation

func (m *MapExperimentOverridesStore) RemoveVariation(overrideKey ExperimentOverrideKey)

RemoveVariation removes the override variation key associated with the argument user+experiment key. If there is no override variation key set, this method has no effect.

func (*MapExperimentOverridesStore) SetVariation

func (m *MapExperimentOverridesStore) SetVariation(overrideKey ExperimentOverrideKey, variationKey string)

SetVariation sets the given variation key as an override for the given user+experiment key

type OptimizelyDecisionContext

type OptimizelyDecisionContext struct {
	FlagKey string
	RuleKey string
}

OptimizelyDecisionContext defines Decision Context

type OptimizelyForcedDecision

type OptimizelyForcedDecision struct {
	VariationKey string
}

OptimizelyForcedDecision defines Forced Decision

type PersistingExperimentService

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

PersistingExperimentService attempts to retrieve a saved decision from the user profile service for the user before having the ExperimentBucketerService compute it. If computed, the decision is saved back to the user profile service if provided.

func NewPersistingExperimentService

func NewPersistingExperimentService(userProfileService UserProfileService, experimentBucketerService ExperimentService, logger logging.OptimizelyLogProducer) *PersistingExperimentService

NewPersistingExperimentService returns a new instance of the PersistingExperimentService

func (PersistingExperimentService) GetDecision

func (p PersistingExperimentService) GetDecision(decisionContext ExperimentDecisionContext, userContext entities.UserContext, options *decide.Options) (experimentDecision ExperimentDecision, reasons decide.DecisionReasons, err error)

GetDecision returns the decision with the variation the user is bucketed into

type RolloutService

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

RolloutService makes a feature decision for a given feature rollout

func NewRolloutService

func NewRolloutService(sdkKey string) *RolloutService

NewRolloutService returns a new instance of the Rollout service

func (RolloutService) GetDecision

func (r RolloutService) GetDecision(decisionContext FeatureDecisionContext, userContext entities.UserContext, options *decide.Options) (FeatureDecision, decide.DecisionReasons, error)

GetDecision returns a decision for the given feature and user context

type Service

Service interface is used to make a decision for a given feature or experiment

type Source

type Source = string

Source is where the decision came from

const (
	// Rollout - the decision came from a rollout
	Rollout Source = "rollout"
	// FeatureTest - the decision came from a feature test
	FeatureTest Source = "feature-test"
)

type UnsafeFeatureDecisionInfo

type UnsafeFeatureDecisionInfo struct {
	Enabled       bool
	VariableMap   map[string]interface{}
	ExperimentKey string
	VariationKey  string
}

UnsafeFeatureDecisionInfo represents response for GetDetailedFeatureDecisionUnsafe api

type UserDecisionKey

type UserDecisionKey struct {
	ExperimentID string
	Field        string
}

UserDecisionKey is used to access the saved decisions in a user profile

func NewUserDecisionKey

func NewUserDecisionKey(experimentID string) UserDecisionKey

NewUserDecisionKey returns a new UserDecisionKey with the given experiment ID

type UserProfile

type UserProfile struct {
	ID                  string
	ExperimentBucketMap map[UserDecisionKey]string
}

UserProfile represents a saved user profile

type UserProfileService

type UserProfileService interface {
	Lookup(string) UserProfile
	Save(UserProfile)
}

UserProfileService is used to save and retrieve past bucketing decisions for users

Directories

Path Synopsis
Package bucketer //
Package bucketer //
Package evaluator //
Package evaluator //
matchers
Package matchers //
Package matchers //
matchers/utils
Package utils //
Package utils //
Package reasons //
Package reasons //

Jump to

Keyboard shortcuts

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