models

package
v0.0.0-...-6cc63a5 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsProjectId

func ContainsProjectId(slice []ProjectId, item ProjectId) bool

func DecodeTreatmentConfig

func DecodeTreatmentConfig(config *structpb.Struct) map[string]interface{}

func ExperimentTreatmentToOpenAPITreatment

func ExperimentTreatmentToOpenAPITreatment(treatment *_pubsub.ExperimentTreatment) schema.SelectedTreatmentData

func OpenAPIExperimentSpecToProtobuf

func OpenAPIExperimentSpecToProtobuf(
	xpExperiment schema.Experiment,
	segmentersType map[string]schema.SegmenterType,
) (*_pubsub.Experiment, error)

func OpenAPIProjectSettingsSpecToProtobuf

func OpenAPIProjectSettingsSpecToProtobuf(projectSettings schema.ProjectSettings) *_pubsub.ProjectSettings

func ProtobufExperimentTypeToOpenAPI

func ProtobufExperimentTypeToOpenAPI(experimentType _pubsub.Experiment_Type) schema.ExperimentType

Types

type ExperimentIndex

type ExperimentIndex struct {
	StartTime time.Time
	EndTime   time.Time

	Experiment *pubsub.Experiment
	// contains filtered or unexported fields
}

func NewExperimentIndex

func NewExperimentIndex(experiment *pubsub.Experiment) *ExperimentIndex

func (*ExperimentIndex) MarshalJSON

func (i *ExperimentIndex) MarshalJSON() ([]byte, error)

MarshalJSON is a custom marshal function that only includes the critical info

type ExperimentIndexLog

type ExperimentIndexLog struct {
	StringSets map[string][]interface{}
	IntSets    map[string][]interface{}
	RealSets   map[string][]interface{}

	StartTime time.Time
	EndTime   time.Time

	ExperimentId int64
	Status       string
	Tier         string
}

ExperimentIndexLog captures the critical information from the ExperimentIndex, in a concise manner, for logging.

type ExperimentMatch

type ExperimentMatch struct {
	Experiment       *pubsub.Experiment
	SegmenterMatches map[string]Match
}

type ExperimentStorage

type ExperimentStorage interface {
	FindExperiments(projectId ProjectId, filters []SegmentFilter) []*ExperimentMatch
	FindExperimentWithId(projectId ProjectId, experimentId int64) *pubsub.Experiment
	InsertExperiment(experiment *pubsub.Experiment)
	DeactivateExperiment(projectId ProjectId, experimentId int64) error
	// DumpExperiments is a helper method for a Debug API
	DumpExperiments(filepath string) error
}

type ExperimentTreatment

type ExperimentTreatment struct {
	Id            *int64                 `json:"id"`
	Configuration map[string]interface{} `json:"configuration"`
	Name          string                 `json:"name"`
	Traffic       *int32                 `json:"traffic,omitempty"`
}

type IntSet

type IntSet = map[int64]interface{}

type LocalStorage

type LocalStorage struct {
	sync.RWMutex
	Experiments     map[ProjectId][]*ExperimentIndex
	ProjectSettings []*pubsub.ProjectSettings

	Segmenters        map[string]schema.SegmenterType
	ProjectSegmenters map[ProjectId]map[string]schema.SegmenterType
	// contains filtered or unexported fields
}

func NewLocalStorage

func NewLocalStorage(
	projectIds []ProjectId,
	xpServer string,
	authzEnabled bool,
	googleApplicationCredentialsEnvVar string,
) (*LocalStorage, error)

func (*LocalStorage) DeleteProjectSegmenters

func (s *LocalStorage) DeleteProjectSegmenters(segmenterName string, projectId int64)

func (*LocalStorage) DumpExperiments

func (s *LocalStorage) DumpExperiments(filepath string) error

DumpExperiments is used to dump the experiment from the local cache into the given file, as JSON. Useful for debugging.

func (*LocalStorage) FindExperimentWithId

func (s *LocalStorage) FindExperimentWithId(projectId ProjectId, experimentId int64) *pubsub.Experiment

func (*LocalStorage) FindExperiments

func (s *LocalStorage) FindExperiments(projectId ProjectId, filters []SegmentFilter) []*ExperimentMatch

func (*LocalStorage) FindProjectSettingsWithId

func (s *LocalStorage) FindProjectSettingsWithId(projectId ProjectId) *pubsub.ProjectSettings

func (*LocalStorage) GetSegmentersTypeMapping

func (s *LocalStorage) GetSegmentersTypeMapping(projectId ProjectId) (map[string]schema.SegmenterType, error)

func (*LocalStorage) InsertExperiment

func (s *LocalStorage) InsertExperiment(experiment *pubsub.Experiment)

func (*LocalStorage) InsertProjectSettings

func (s *LocalStorage) InsertProjectSettings(projectSettings *pubsub.ProjectSettings) error

func (*LocalStorage) UpdateExperiment

func (s *LocalStorage) UpdateExperiment(experiment *pubsub.Experiment)

func (*LocalStorage) UpdateProjectSegmenters

func (s *LocalStorage) UpdateProjectSegmenters(segmenter *_segmenters.SegmenterConfiguration, projectId int64)

func (*LocalStorage) UpdateProjectSettings

func (s *LocalStorage) UpdateProjectSettings(updatedProjectSettings *pubsub.ProjectSettings)

type Match

type Match struct {
	Strength MatchStrength
	Value    *_segmenters.SegmenterValue
}

type MatchStrength

type MatchStrength string
const (
	MatchStrengthExact MatchStrength = "exact"
	MatchStrengthWeak  MatchStrength = "weak"
	MatchStrengthNone  MatchStrength = "none"
)

type ProjectId

type ProjectId = uint32

func NewProjectId

func NewProjectId(id int64) ProjectId

type ProjectSettingsStorage

type ProjectSettingsStorage interface {
	FindProjectSettingsWithId(projectId ProjectId) *pubsub.ProjectSettings
}

type RealSet

type RealSet = map[float64]interface{}

type SegmentFilter

type SegmentFilter struct {
	Key   string
	Value []*_segmenters.SegmenterValue
}

type StringSet

type StringSet = map[string]interface{}

Jump to

Keyboard shortcuts

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