eppoclient

package
v5.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package eppoclient provides client for eppo.cloud. Check InitClient to get started.

Index

Constants

View Source
const BANDIT_ENDPOINT = "/flag-config/v1/bandits"
View Source
const CONFIG_ENDPOINT = "/flag-config/v1/config"
View Source
const REQUEST_TIMEOUT_SECONDS = time.Duration(10 * time.Second)

Variables

View Source
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 BanditResult struct {
	Variation string
	Action    *string
}

type Config

type Config struct {
	BaseUrl           string
	SdkKey            string
	AssignmentLogger  IAssignmentLogger
	PollerInterval    time.Duration
	ApplicationLogger applicationlogger.Logger
}

type ContextAttributes

type ContextAttributes struct {
	Numeric     map[string]float64
	Categorical map[string]string
}

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)

type SDKParams

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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