eppoclient

package
v6.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 17 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 ApplicationLogger

type ApplicationLogger interface {
	Debug(args ...interface{})
	Info(args ...interface{})
	Infof(template string, args ...interface{})
	Warn(args ...interface{})
	Warnf(template string, args ...interface{})
	Error(args ...interface{})
	Errorf(template string, args ...interface{})
}

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
}

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) GetJSONBytesAssignment

func (ec *EppoClient) GetJSONBytesAssignment(flagKey string, subjectKey string, subjectAttributes Attributes, defaultValue []byte) ([]byte, 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)

func (*EppoClient) Initialized added in v6.1.0

func (ec *EppoClient) Initialized() <-chan struct{}

Returns a channel that gets closed after client has been *successfully* initialized.

It is recommended to apply a timeout to initialization as otherwise it may hang up indefinitely.

select {
case <-client.Initialized():
case <-time.After(5 * time.Second):
}

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

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

func (lal *LruAssignmentLogger) LogBanditAction(event BanditEvent)

type LruBanditLogger

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

func (*LruBanditLogger) LogAssignment

func (logger *LruBanditLogger) LogAssignment(event AssignmentEvent)

func (*LruBanditLogger) LogBanditAction

func (logger *LruBanditLogger) LogBanditAction(event BanditEvent)

type SDKParams

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

type ScrubbingLogger

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

ScrubbingLogger is an ApplicationLogger that scrubs sensitive information from logs

func NewScrubbingLogger

func NewScrubbingLogger(innerLogger ApplicationLogger) *ScrubbingLogger

func (*ScrubbingLogger) Debug

func (s *ScrubbingLogger) Debug(args ...interface{})

func (*ScrubbingLogger) Error

func (s *ScrubbingLogger) Error(args ...interface{})

func (*ScrubbingLogger) Errorf

func (s *ScrubbingLogger) Errorf(template string, args ...interface{})

func (*ScrubbingLogger) Info

func (s *ScrubbingLogger) Info(args ...interface{})

func (*ScrubbingLogger) Infof

func (s *ScrubbingLogger) Infof(template string, args ...interface{})

func (*ScrubbingLogger) Warn

func (s *ScrubbingLogger) Warn(args ...interface{})

func (*ScrubbingLogger) Warnf

func (s *ScrubbingLogger) Warnf(template string, args ...interface{})

type ZapLogger

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

ZapLogger The default logger for the Eppo SDK

func NewZapLogger

func NewZapLogger(logger *zap.Logger) *ZapLogger

func (*ZapLogger) Debug

func (z *ZapLogger) Debug(args ...interface{})

func (*ZapLogger) Error

func (z *ZapLogger) Error(args ...interface{})

func (*ZapLogger) Errorf

func (z *ZapLogger) Errorf(template string, args ...interface{})

func (*ZapLogger) Info

func (z *ZapLogger) Info(args ...interface{})

func (*ZapLogger) Infof

func (z *ZapLogger) Infof(template string, args ...interface{})

func (*ZapLogger) Warn

func (z *ZapLogger) Warn(args ...interface{})

func (*ZapLogger) Warnf

func (z *ZapLogger) Warnf(template string, args ...interface{})

Jump to

Keyboard shortcuts

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