manager

package
v0.0.0-...-20989ac Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCacheEnabled

func IsCacheEnabled(expManager ExperimentManager) bool

func IsStandardExperimentManager

func IsStandardExperimentManager(expManager ExperimentManager) bool

func ListVariablesForExperiments

func ListVariablesForExperiments(expManager ExperimentManager, exps []Experiment) (map[string][]Variable, error)

Types

type BaseStandardExperimentManager

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

BaseStandardExperimentManager provides dummy implementations for the optional StandardExperimentManager methods and can be composed into other concrete implementations of the interface to provide the base behavior.

func NewBaseStandardExperimentManager

func NewBaseStandardExperimentManager(info Engine) *BaseStandardExperimentManager

NewBaseStandardExperimentManager is a constructor for the base experiment manager

func (*BaseStandardExperimentManager) GetEngineInfo

func (em *BaseStandardExperimentManager) GetEngineInfo() (Engine, error)

func (*BaseStandardExperimentManager) IsCacheEnabled

func (*BaseStandardExperimentManager) IsCacheEnabled() (bool, error)

func (*BaseStandardExperimentManager) ListClients

func (*BaseStandardExperimentManager) ListClients() ([]Client, error)

func (*BaseStandardExperimentManager) ListExperiments

func (*BaseStandardExperimentManager) ListExperiments() ([]Experiment, error)

func (*BaseStandardExperimentManager) ListExperimentsForClient

func (*BaseStandardExperimentManager) ListExperimentsForClient(Client) ([]Experiment, error)

func (*BaseStandardExperimentManager) ListVariablesForClient

func (*BaseStandardExperimentManager) ListVariablesForClient(Client) ([]Variable, error)

func (*BaseStandardExperimentManager) ListVariablesForExperiments

func (*BaseStandardExperimentManager) ListVariablesForExperiments([]Experiment) (map[string][]Variable, error)

func (*BaseStandardExperimentManager) ValidateExperimentConfig

func (em *BaseStandardExperimentManager) ValidateExperimentConfig(cfg json.RawMessage) error

type Client

type Client struct {
	ID       string `json:"id" validate:"required"`
	Username string `json:"username" validate:"required"`
	Passkey  string `json:"passkey,omitempty"`
}

Client describes the properties of a client registered on an experiment engine

func ListClients

func ListClients(expManager ExperimentManager) ([]Client, error)

type CustomExperimentManager

type CustomExperimentManager interface {
	ExperimentManager
}

type CustomExperimentManagerConfig

type CustomExperimentManagerConfig struct {
	// RemoteUI specifies the information for the custom experiment engine UI to be
	// consumed by the Turing app, using Module Federation
	RemoteUI RemoteUI `json:"remote_ui"`
	// ExperimentConfigSchema is the serialised schema as supported by https://github.com/WASD-Team/yup-ast.
	// If set, it will be used by the UI to validate experiment engine configuration in the Turing router.
	ExperimentConfigSchema string `json:"experiment_config_schema,omitempty"`
}

type Engine

type Engine struct {
	// Name is the unique identifier for the experiment engine and will be used as
	// the display name in the UI if the optional `DisplayName` field is not set.
	Name string `json:"name"`
	// DisplayName is the name of the experiment engine that will be used in the UI,
	// solely for the purpose of display. The Turing API still relies on the `Name`.
	DisplayName string `json:"display_name"`
	// Type describes the class of the experiment engine manager
	Type ExperimentManagerType `json:"type"`
	// StandardExperimentManagerConfig is expected to be set by a "standard" experiment engine manager
	// and is used by the generic Turing experiment engine UI.
	StandardExperimentManagerConfig *StandardExperimentManagerConfig `json:"standard_experiment_manager_config,omitempty"`
	// CustomExperimentManagerConfig is expected to be set by a "custom" experiment engine manager
	// and is used to load the custom experiment engine UI.
	CustomExperimentManagerConfig *CustomExperimentManagerConfig `json:"custom_experiment_manager_config,omitempty"`
}

Engine describes the properties of an experiment engine

type Experiment

type Experiment struct {
	ID       string    `json:"id" validate:"required"`
	Name     string    `json:"name" validate:"required"`
	ClientID string    `json:"client_id"`
	Variants []Variant `json:"variants"`
}

Experiment describes the properties of an experiment registered on an experiment engine

func ListExperiments

func ListExperiments(expManager ExperimentManager) ([]Experiment, error)

func ListExperimentsForClient

func ListExperimentsForClient(expManager ExperimentManager, client Client) ([]Experiment, error)

type ExperimentManager

type ExperimentManager interface {
	// GetEngineInfo returns the configuration of the experiment engine
	GetEngineInfo() (Engine, error)

	// ValidateExperimentConfig validates the given Turing experiment config for the expected data and format
	ValidateExperimentConfig(cfg json.RawMessage) error

	// GetExperimentRunnerConfig converts the given config (as retrieved from the DB) into a format suitable
	// for the Turing router (i.e., to be passed to the Experiment Runner). This interface method will be
	// called at the time of router deployment.
	//
	// cfg holds the experiment configuration in a format that is suitable for use with the Turing UI and
	// this is the data that is saved to the Turing DB.
	//
	// In case of StandardExperimentManager, cfg is expected to be unmarshalled into TuringExperimentConfig
	GetExperimentRunnerConfig(cfg json.RawMessage) (json.RawMessage, error)
}

ExperimentManager describes the minimal set of methods to be implemented by an experiment engine's Manager, providing access to the information required to set up experiments on Turing.

type ExperimentManagerType

type ExperimentManagerType string
var (
	StandardExperimentManagerType ExperimentManagerType = "standard"
	CustomExperimentManagerType   ExperimentManagerType = "custom"
)

type RemoteUI

type RemoteUI struct {
	// Name is the name of the remote app declared in the Module Federation plugin
	Name string `json:"name"`
	// URL is the Host + Remote Entry file at which the remote UI can be found
	URL string `json:"url"`
	// Config is an optional URL that will be loaded at run-time, to provide the experiment engine
	// configs dynamically
	Config string `json:"config,omitempty"`
}

type StandardExperimentManager

type StandardExperimentManager interface {
	ExperimentManager
	// IsCacheEnabled returns whether the experiment engine wants to cache its responses in the Turing API cache
	IsCacheEnabled() (bool, error)
	// ListClients returns a list of the clients registered on the experiment engine
	ListClients() ([]Client, error)
	// ListExperiments returns a list of the experiments registered on the experiment engine
	ListExperiments() ([]Experiment, error)
	// ListExperimentsForClient returns a list of the experiments registered on the experiment engine,
	// for the given client
	ListExperimentsForClient(Client) ([]Experiment, error)
	// ListVariablesForClient returns a list of the variables registered on the given client
	ListVariablesForClient(Client) ([]Variable, error)
	// ListVariablesForExperiments returns a list of the variables registered on the given experiments
	ListVariablesForExperiments([]Experiment) (map[string][]Variable, error)
}

type StandardExperimentManagerConfig

type StandardExperimentManagerConfig struct {
	// ClientSelectionEnabled is set to true if the experiment engine has the concept of
	// clients, that can be used to authenticate the experiment run requests.
	ClientSelectionEnabled bool `json:"client_selection_enabled"`
	// ExperimentSelectionEnabled is set to true if the experiment engine allows selecting
	// individual experiments configured elsewhere
	ExperimentSelectionEnabled bool `json:"experiment_selection_enabled"`
	// HomePageURL is an optional string which, if set, will be used by the UI to redirect
	// to the experiment engine's home page, to view more details on the experiment
	// configured in Turing.
	HomePageURL string `json:"home_page_url"`
}

type TuringExperimentConfig

type TuringExperimentConfig struct {
	Client      Client       `json:"client" validate:"dive"`
	Experiments []Experiment `json:"experiments" validate:"dive"`
	Variables   Variables    `json:"variables" validate:"dive"`
}

TuringExperimentConfig is the saved experiment config on Turing, when using the generic UI, that captures the key pieces of info about the experiment engine

func ParseStandardExperimentConfig

func ParseStandardExperimentConfig(raw json.RawMessage) (stdExpCfg TuringExperimentConfig, err error)

type Variable

type Variable struct {
	Name     string       `json:"name" validate:"required"`
	Required bool         `json:"required"`
	Type     VariableType `json:"type" validate:"required"`
}

Variable describes the properties of a variable registered on a client / experiment

func ListVariablesForClient

func ListVariablesForClient(expManager ExperimentManager, client Client) ([]Variable, error)

type VariableConfig

type VariableConfig struct {
	Name        string              `json:"name" validate:"required"`
	Required    bool                `json:"required"`
	Field       string              `json:"field" validate:"required_with=Required"`
	FieldSource request.FieldSource `json:"field_source" validate:"field-src"`
}

VariableConfig describes the request parsing configuration for a variable

type VariableType

type VariableType string

VariableType is used to describe experiment variables

const (
	// UnsupportedVariableType variable type is used when the experiment engine does not classify
	// the variable (None) or the type is not known or relevant to the API
	UnsupportedVariableType VariableType = "unsupported"
	// UnitVariableType variable type is used for variables that as experiment units (typically,
	// their hash is used to randomly assign variants / parameter values)
	UnitVariableType VariableType = "unit"
	// FilterVariableType variable type is used for variables that act as filters (i.e., if the
	// incoming value for the variable in a request does nt fit certain criteria, the experiment is
	// considered to be not applicable)
	FilterVariableType VariableType = "filter"
)

type Variables

type Variables struct {
	// ClientVariables represents the list of variables configured on the experiment engine's
	// client, if applicable
	ClientVariables []Variable `json:"client_variables" validate:"dive"`
	// ExperimentVariables is a map of experiment_id -> []Variable, representing the
	// variables configured on each experiment on the experiment engine
	ExperimentVariables map[string][]Variable `json:"experiment_variables" validate:"dive,dive"`
	// Config represents the request parsing configuration for all the Turing experiment variables
	Config []VariableConfig `json:"config" validate:"dive"`
}

Variables represents the configuration of all experiment variables

type Variant

type Variant struct {
	Name string `json:"name"`
}

Variant describes the properties of a variant registered on an experiment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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