Documentation
¶
Overview ¶
Package eppoclient provides client for eppo.cloud. Check InitClient to get started.
Index ¶
- Constants
- Variables
- type AssignmentEvent
- type AssignmentLogger
- type Attributes
- type BanditActionLogger
- type BanditEvent
- type BanditResult
- type Config
- type ContextAttributes
- type EppoClient
- func (ec *EppoClient) GetBanditAction(flagKey string, subjectKey string, subjectAttributes ContextAttributes, ...) BanditResult
- func (ec *EppoClient) GetBoolAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, ...) (bool, error)
- func (ec *EppoClient) GetIntegerAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, ...) (int64, error)
- func (ec *EppoClient) GetJSONAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, ...) (interface{}, error)
- func (ec *EppoClient) GetNumericAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, ...) (float64, error)
- func (ec *EppoClient) GetStringAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, ...) (string, error)
- type IAssignmentLogger
- type LruAssignmentLogger
- type LruBanditLogger
- type SDKParams
Constants ¶
const BANDIT_ENDPOINT = "/flag-config/v1/bandits"
const CONFIG_ENDPOINT = "/flag-config/v1/config"
const REQUEST_TIMEOUT_SECONDS = time.Duration(10 * time.Second)
Variables ¶
var ( ErrSubjectAllocation = errors.New("subject is not part of any allocation") ErrFlagNotEnabled = errors.New("the experiment or flag is not enabled") ErrFlagConfigurationNotFound = errors.New("flag configuration not found") ErrBanditConfigurationNotFound = errors.New("bandit configuration not found") )
Functions ¶
This section is empty.
Types ¶
type AssignmentEvent ¶
type AssignmentEvent struct { Experiment string `json:"experiment"` FeatureFlag string `json:"featureFlag"` Allocation string `json:"allocation"` Variation string `json:"variation"` Subject string `json:"subject"` SubjectAttributes Attributes `json:"subjectAttributes,omitempty"` Timestamp string `json:"timestamp"` MetaData map[string]string `json:"metaData"` ExtraLogging map[string]string `json:"extraLogging,omitempty"` }
type AssignmentLogger ¶
type AssignmentLogger struct { }
func (*AssignmentLogger) LogAssignment ¶
func (al *AssignmentLogger) LogAssignment(event AssignmentEvent)
func (*AssignmentLogger) LogBanditAction ¶
func (al *AssignmentLogger) LogBanditAction(event BanditEvent)
type Attributes ¶
type Attributes map[string]interface{}
type BanditActionLogger ¶
type BanditActionLogger interface {
LogBanditAction(event BanditEvent)
}
BanditActionLogger is going to be merged into IAssignmentLogger in the next major version.
type BanditEvent ¶
type BanditEvent struct { FlagKey string `json:"flagKey"` BanditKey string `json:"banditKey"` Subject string `json:"subject"` Action string `json:"action,omitempty"` ActionProbability float64 `json:"actionProbability,omitempty"` OptimalityGap float64 `json:"optimalityGap,omitempty"` ModelVersion string `json:"modelVersion,omitempty"` Timestamp string `json:"timestamp"` SubjectNumericAttributes map[string]float64 `json:"subjectNumericAttributes,omitempty"` SubjectCategoricalAttributes map[string]string `json:"subjectCategoricalAttributes,omitempty"` ActionNumericAttributes map[string]float64 `json:"actionNumericAttributes,omitempty"` ActionCategoricalAttributes map[string]string `json:"actionCategoricalAttributes,omitempty"` MetaData map[string]string `json:"metaData"` }
type BanditResult ¶
type Config ¶
type Config struct { BaseUrl string SdkKey string AssignmentLogger IAssignmentLogger PollerInterval time.Duration ApplicationLogger applicationlogger.Logger }
type ContextAttributes ¶
func InferContextAttributes ¶
func InferContextAttributes(attrs map[string]interface{}) ContextAttributes
Tries to map generic attributes to ContextAttributes depending on attribute types. - Integer and float types are mapped to numeric attributes. - Strings and bools are mapped to categorical attributes. - Rest of types are silently dropped.
type EppoClient ¶
type EppoClient struct {
// contains filtered or unexported fields
}
EppoClient Client for eppo.cloud. Instance of this struct will be created on calling InitClient. EppoClient will then immediately start polling experiments data from Eppo.
func InitClient ¶
func InitClient(config Config) (*EppoClient, error)
InitClient is required to start polling of experiments configurations and create an instance of EppoClient, which could be used to get assignments information.
func (*EppoClient) GetBanditAction ¶
func (ec *EppoClient) GetBanditAction(flagKey string, subjectKey string, subjectAttributes ContextAttributes, actions map[string]ContextAttributes, defaultVariation string) BanditResult
func (*EppoClient) GetBoolAssignment ¶
func (ec *EppoClient) GetBoolAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, defaultValue bool) (bool, error)
func (*EppoClient) GetIntegerAssignment ¶
func (ec *EppoClient) GetIntegerAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, defaultValue int64) (int64, error)
func (*EppoClient) GetJSONAssignment ¶
func (ec *EppoClient) GetJSONAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, defaultValue interface{}) (interface{}, error)
func (*EppoClient) GetNumericAssignment ¶
func (ec *EppoClient) GetNumericAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, defaultValue float64) (float64, error)
func (*EppoClient) GetStringAssignment ¶
func (ec *EppoClient) GetStringAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, defaultValue string) (string, error)
type IAssignmentLogger ¶
type IAssignmentLogger interface {
LogAssignment(event AssignmentEvent)
}
func NewAssignmentLogger ¶
func NewAssignmentLogger() IAssignmentLogger
func NewLruAssignmentLogger ¶
func NewLruAssignmentLogger(logger IAssignmentLogger, cacheSize int) (IAssignmentLogger, error)
func NewLruBanditLogger ¶ added in v5.2.0
func NewLruBanditLogger(logger IAssignmentLogger, cacheSize int) (IAssignmentLogger, error)
type LruAssignmentLogger ¶
type LruAssignmentLogger struct {
// contains filtered or unexported fields
}
func (*LruAssignmentLogger) LogAssignment ¶
func (lal *LruAssignmentLogger) LogAssignment(event AssignmentEvent)
func (*LruAssignmentLogger) LogBanditAction ¶ added in v5.2.0
func (lal *LruAssignmentLogger) LogBanditAction(event BanditEvent)
type LruBanditLogger ¶ added in v5.2.0
type LruBanditLogger struct {
// contains filtered or unexported fields
}
func (*LruBanditLogger) LogAssignment ¶ added in v5.2.0
func (logger *LruBanditLogger) LogAssignment(event AssignmentEvent)
func (*LruBanditLogger) LogBanditAction ¶ added in v5.2.0
func (logger *LruBanditLogger) LogBanditAction(event BanditEvent)