eppoclient

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 16 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

This section is empty.

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 added in v4.1.0

func (al *AssignmentLogger) LogBanditAction(event BanditEvent)

type Attributes

type Attributes map[string]interface{}

type BanditActionLogger added in v4.1.0

type BanditActionLogger interface {
	LogBanditAction(event BanditEvent)
}

BanditActionLogger is going to be merged into IAssignmentLogger in the next major version.

type BanditEvent added in v4.1.0

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 added in v4.1.0

type BanditResult struct {
	Variation string
	Action    *string
}

type Config

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

type ContextAttributes added in v4.1.0

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

func InferContextAttributes added in v4.1.0

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
}

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

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 added in v4.1.0

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

type LruAssignmentLogger

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

func (*LruAssignmentLogger) LogAssignment

func (self *LruAssignmentLogger) LogAssignment(event AssignmentEvent)

type SDKParams

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

Jump to

Keyboard shortcuts

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