Documentation
¶
Index ¶
- Constants
- Variables
- func CheckRulePredicate(predicate string) error
- func ValidateTreatmentConfigWithTreatmentSchema(treatmentConfig map[string]interface{}, ...) error
- type ConfigurationService
- type CreateCustomSegmenterRequestBody
- type CreateExperimentRequestBody
- type CreateProjectSettingsRequestBody
- type CreateSegmentRequestBody
- type CreateTreatmentRequestBody
- type EntityType
- type ExperimentHistoryService
- type ExperimentService
- type ExperimentStatusFriendly
- type ListExperimentHistoryParams
- type ListExperimentsParams
- type ListSegmentHistoryParams
- type ListSegmentersParams
- type ListSegmentsParams
- type ListTreatmentHistoryParams
- type ListTreatmentsParams
- type MLPService
- type OperationType
- type ProjectSettingsService
- type SegmentHistoryService
- type SegmentService
- type SegmenterScope
- type SegmenterService
- type SegmenterStatus
- type Services
- type TreatmentHistoryService
- type TreatmentService
- type UpdateCustomSegmenterRequestBody
- type UpdateExperimentRequestBody
- type UpdateProjectSettingsRequestBody
- type UpdateSegmentRequestBody
- type UpdateTreatmentRequestBody
- type ValidationContext
- type ValidationService
Constants ¶
View Source
const PASSKEY_LENGTH = 32
Variables ¶
View Source
var ( SegmenterScopeMap = map[string]SegmenterScope{ "global": SegmenterScopeGlobal, "project": SegmenterScopeProject, } SegmenterStatusMap = map[string]SegmenterStatus{ "active": SegmenterStatusActive, "inactive": SegmenterStatusInactive, } )
Functions ¶
func CheckRulePredicate ¶
CheckRulePredicate checks if a given predicate is a valid Go template expression
func ValidateTreatmentConfigWithTreatmentSchema ¶
func ValidateTreatmentConfigWithTreatmentSchema( treatmentConfig map[string]interface{}, treatmentSchema *models.TreatmentSchema, ) error
ValidateTreatmentConfigWithTreatmentSchema validates the given treatment config by running it against all the rules in the treatment schema concurrently; if any one of these rules return an error, this method returns an error
Types ¶
type ConfigurationService ¶
type ConfigurationService interface {
GetTreatmentServiceConfig() schema.TreatmentServiceConfig
}
func NewConfigurationService ¶
func NewConfigurationService(cfg *config.Config) ConfigurationService
type CreateCustomSegmenterRequestBody ¶
type CreateCustomSegmenterRequestBody struct {
Name string `json:"name" validate:"required,notBlank"`
Type string `json:"type" validate:"notBlank"`
Options *models.Options `json:"options"`
MultiValued bool `json:"multi_valued"`
Constraints *models.Constraints `json:"constraints"`
Required bool `json:"required"`
Description *string `json:"description,omitempty"`
}
type CreateExperimentRequestBody ¶
type CreateExperimentRequestBody struct {
Description *string `json:"description"`
EndTime time.Time `json:"end_time" validate:"required,gtfield=StartTime"`
Interval *int32 `json:"interval"`
Name string `json:"name" validate:"required,notBlank"`
Segment models.ExperimentSegmentRaw `json:"segment"`
StartTime time.Time `json:"start_time" validate:"required"`
Status models.ExperimentStatus `json:"status" validate:"required,oneof=inactive active"`
Treatments models.ExperimentTreatments `json:"treatments" validate:"unique=Name,dive,required,notBlank"`
Tier models.ExperimentTier `json:"tier" validate:"required,oneof=default override"`
Type models.ExperimentType `json:"type" validate:"required,oneof=A/B Switchback"`
UpdatedBy *string `json:"updated_by,omitempty"`
}
type CreateProjectSettingsRequestBody ¶
type CreateProjectSettingsRequestBody struct {
EnableS2idClustering *bool `json:"enable_s2id_clustering,omitempty"`
RandomizationKey string `json:"randomization_key" validate:"required,notBlank"`
Segmenters models.ProjectSegmenters `json:"segmenters" validate:"required"`
TreatmentSchema *models.TreatmentSchema `json:"treatment_schema" validate:"omitempty"`
ValidationUrl *string `json:"validation_url" validate:"omitempty,url"`
Username string `json:"username" validate:"required,notBlank"`
}
type CreateSegmentRequestBody ¶
type CreateSegmentRequestBody struct {
Segment models.ExperimentSegmentRaw `json:"segment" validate:"required,notBlank"`
Name string `json:"name" validate:"required,notBlank"`
UpdatedBy *string `json:"updated_by,omitempty"`
}
type EntityType ¶
type EntityType string
const ( EntityTypeExperiment EntityType = "experiment" EntityTypeTreatment EntityType = "treatment" EntityTypeSegment EntityType = "segment" )
type ExperimentHistoryService ¶
type ExperimentHistoryService interface {
ListExperimentHistory(experimentId int64, params ListExperimentHistoryParams) ([]*models.ExperimentHistory, *pagination.Paging, error)
GetExperimentHistory(experimentId int64, version int64) (*models.ExperimentHistory, error)
CreateExperimentHistory(*models.Experiment) (*models.ExperimentHistory, error)
GetDBRecord(experimentId models.ID, version int64) (*models.ExperimentHistory, error)
}
func NewExperimentHistoryService ¶
func NewExperimentHistoryService(db *gorm.DB) ExperimentHistoryService
type ExperimentService ¶
type ExperimentService interface {
ListExperiments(
projectId int64,
params ListExperimentsParams,
) ([]*models.Experiment, *pagination.Paging, error)
ListAllExperiments(projectId models.ID, params ListExperimentsParams) ([]*models.Experiment, error)
GetExperiment(projectId int64, experimentId int64) (*models.Experiment, error)
CreateExperiment(settings models.Settings, expData CreateExperimentRequestBody) (*models.Experiment, error)
UpdateExperiment(settings models.Settings, experimentId int64, expData UpdateExperimentRequestBody) (*models.Experiment, error)
EnableExperiment(settings models.Settings, experimentId int64) error
DisableExperiment(projectId int64, experimentId int64) error
ValidatePairwiseExperimentOrthogonality(projectId int64, experiments []*models.Experiment, segmenters []string) error
ValidateProjectExperimentSegmentersExist(projectId int64, experiments []*models.Experiment, segmenters []string) error
GetDBRecord(projectId models.ID, experimentId models.ID) (*models.Experiment, error)
RunCustomValidation(
experiment models.Experiment,
settings models.Settings,
context ValidationContext,
operationType OperationType,
) error
}
func NewExperimentService ¶
func NewExperimentService( services *Services, db *gorm.DB, ) ExperimentService
type ExperimentStatusFriendly ¶
type ExperimentStatusFriendly string
const ( ExperimentStatusFriendlyCompleted ExperimentStatusFriendly = "completed" ExperimentStatusFriendlyDeactivated ExperimentStatusFriendly = "deactivated" ExperimentStatusFriendlyRunning ExperimentStatusFriendly = "running" ExperimentStatusFriendlyScheduled ExperimentStatusFriendly = "scheduled" )
Defines values for ExperimentStatusFriendly.
type ListExperimentHistoryParams ¶
type ListExperimentHistoryParams struct {
pagination.PaginationOptions
}
type ListExperimentsParams ¶
type ListExperimentsParams struct {
pagination.PaginationOptions
Status *models.ExperimentStatus `json:"status,omitempty"`
StatusFriendly []ExperimentStatusFriendly `json:"status_friendly"`
EndTime *time.Time `json:"end_time,omitempty"`
Tier *models.ExperimentTier `json:"tier,omitempty"`
Type *models.ExperimentType `json:"type,omitempty"`
Name *string `json:"name,omitempty"`
UpdatedBy *string `json:"updated_by,omitempty"`
Search *string `json:"search,omitempty"`
StartTime *time.Time `json:"start_time,omitempty"`
Segment models.ExperimentSegment `json:"segment,omitempty"`
IncludeWeakMatch bool `json:"include_weak_match"`
Fields *[]models.ExperimentField `json:"fields,omitempty"`
}
type ListSegmentHistoryParams ¶
type ListSegmentHistoryParams struct {
pagination.PaginationOptions
}
type ListSegmentersParams ¶
type ListSegmentersParams struct {
Scope *SegmenterScope `json:"scope,omitempty"`
Status *SegmenterStatus `json:"status,omitempty"`
Search *string `json:"search,omitempty"`
}
type ListSegmentsParams ¶
type ListSegmentsParams struct {
pagination.PaginationOptions
UpdatedBy *string `json:"updated_by,omitempty"`
Search *string `json:"search,omitempty"`
Fields *[]models.SegmentField `json:"fields,omitempty"`
}
type ListTreatmentHistoryParams ¶
type ListTreatmentHistoryParams struct {
pagination.PaginationOptions
}
type ListTreatmentsParams ¶
type ListTreatmentsParams struct {
pagination.PaginationOptions
UpdatedBy *string `json:"updated_by,omitempty"`
Search *string `json:"search,omitempty"`
Fields *[]models.TreatmentField `json:"fields,omitempty"`
}
type MLPService ¶
type MLPService interface {
// GetProject gets the project matching the provided id
GetProject(id int64) (*mlp.Project, error)
}
MLPService provides a set of methods to interact with the MLP APIs
func NewMLPService ¶
func NewMLPService(mlpBasePath string) (MLPService, error)
NewMLPService returns a service that retrieves information that is shared across MLP projects.
type OperationType ¶
type OperationType string
const ( OperationTypeCreate OperationType = "create" OperationTypeUpdate OperationType = "update" )
type ProjectSettingsService ¶
type ProjectSettingsService interface {
ListProjects() (*[]models.Project, error)
GetProjectSettings(projectId int64) (*models.Settings, error)
GetExperimentVariables(projectId int64) (*[]string, error)
CreateProjectSettings(projectId int64, settings CreateProjectSettingsRequestBody) (*models.Settings, error)
UpdateProjectSettings(projectId int64, settings UpdateProjectSettingsRequestBody) (*models.Settings, error)
GetDBRecord(projectId models.ID) (*models.Settings, error)
}
func NewProjectSettingsService ¶
func NewProjectSettingsService(services *Services, db *gorm.DB) ProjectSettingsService
type SegmentHistoryService ¶
type SegmentHistoryService interface {
ListSegmentHistory(segmentId int64, params ListSegmentHistoryParams) ([]*models.SegmentHistory, *pagination.Paging, error)
GetSegmentHistory(segmentId int64, version int64) (*models.SegmentHistory, error)
CreateSegmentHistory(*models.Segment) (*models.SegmentHistory, error)
GetDBRecord(segmentId models.ID, version int64) (*models.SegmentHistory, error)
DeleteSegmentHistory(segmentId int64) error
}
func NewSegmentHistoryService ¶
func NewSegmentHistoryService(db *gorm.DB) SegmentHistoryService
type SegmentService ¶
type SegmentService interface {
ListSegments(
projectId int64,
params ListSegmentsParams,
) ([]*models.Segment, *pagination.Paging, error)
GetSegment(projectId int64, segmentId int64) (*models.Segment, error)
CreateSegment(settings models.Settings, segmentData CreateSegmentRequestBody) (*models.Segment, error)
UpdateSegment(settings models.Settings, segmentId int64, segmentData UpdateSegmentRequestBody) (*models.Segment, error)
DeleteSegment(projectId int64, segmentId int64) error
GetDBRecord(projectId models.ID, segmentId models.ID) (*models.Segment, error)
}
func NewSegmentService ¶
func NewSegmentService(services *Services, db *gorm.DB) SegmentService
type SegmenterScope ¶
type SegmenterScope string
const ( SegmenterScopeGlobal SegmenterScope = "global" SegmenterScopeProject SegmenterScope = "project" )
type SegmenterService ¶
type SegmenterService interface {
GetFormattedSegmenters(projectId int64, expSegment models.ExperimentSegmentRaw) (map[string]*[]interface{}, error)
GetSegmenterConfigurations(projectId int64, segmenterNames []string) ([]*_segmenters.SegmenterConfiguration, error)
ValidateExperimentSegment(projectId int64, userSegmenters []string, expSegment models.ExperimentSegmentRaw) error
ValidateSegmentOrthogonality(
projectId int64,
userSegmenters []string,
expSegment models.ExperimentSegmentRaw,
allExps []models.Experiment,
) error
ValidatePrereqSegmenters(projectId int64, segmenters []string) error
ValidateRequiredSegmenters(projectId int64, segmenters []string) error
ValidateExperimentVariables(projectId int64, projectSegmenters models.ProjectSegmenters) error
GetSegmenter(projectId int64, name string) (*schema.Segmenter, error)
ListSegmenters(projectId int64, params ListSegmentersParams) ([]*schema.Segmenter, error)
ListGlobalSegmenters() ([]*schema.Segmenter, error)
GetCustomSegmenter(projectId int64, name string) (*models.CustomSegmenter, error)
CreateCustomSegmenter(
projectId int64,
customSegmenterData CreateCustomSegmenterRequestBody,
) (*models.CustomSegmenter, error)
UpdateCustomSegmenter(
projectId int64,
name string,
customSegmenterData UpdateCustomSegmenterRequestBody,
) (*models.CustomSegmenter, error)
DeleteCustomSegmenter(projectId int64, name string) error
GetDBRecord(projectId models.ID, name string) (*models.CustomSegmenter, error)
GetSegmenterTypes(projectId int64) (map[string]schema.SegmenterType, error)
}
func NewSegmenterService ¶
type SegmenterStatus ¶
type SegmenterStatus string
const ( SegmenterStatusActive SegmenterStatus = "active" SegmenterStatusInactive SegmenterStatus = "inactive" )
type Services ¶
type Services struct {
ExperimentService ExperimentService
ExperimentHistoryService ExperimentHistoryService
SegmenterService SegmenterService
MLPService MLPService
ProjectSettingsService ProjectSettingsService
SegmentService SegmentService
SegmentHistoryService SegmentHistoryService
TreatmentService TreatmentService
TreatmentHistoryService TreatmentHistoryService
ValidationService ValidationService
MessageQueueService messagequeue.MessageQueueService
ConfigurationService ConfigurationService
}
func NewServices ¶
func NewServices( expSvc ExperimentService, expHistorySvc ExperimentHistoryService, segmenterSvc SegmenterService, mlpSvc MLPService, projectSettingsSvc ProjectSettingsService, segmentSvc SegmentService, segmentHistorySvc SegmentHistoryService, treatmentSvc TreatmentService, treatmentHistorySvc TreatmentHistoryService, validationSvc ValidationService, messageQueueSvc messagequeue.MessageQueueService, configurationService ConfigurationService, ) Services
type TreatmentHistoryService ¶
type TreatmentHistoryService interface {
ListTreatmentHistory(treatmentId int64, params ListTreatmentHistoryParams) ([]*models.TreatmentHistory, *pagination.Paging, error)
GetTreatmentHistory(treatmentId int64, version int64) (*models.TreatmentHistory, error)
CreateTreatmentHistory(*models.Treatment) (*models.TreatmentHistory, error)
GetDBRecord(treatmentId models.ID, version int64) (*models.TreatmentHistory, error)
DeleteTreatmentHistory(treatmentId int64) error
}
func NewTreatmentHistoryService ¶
func NewTreatmentHistoryService(db *gorm.DB) TreatmentHistoryService
type TreatmentService ¶
type TreatmentService interface {
ListTreatments(
projectId int64,
params ListTreatmentsParams,
) ([]*models.Treatment, *pagination.Paging, error)
GetTreatment(projectId int64, treatmentId int64) (*models.Treatment, error)
CreateTreatment(settings models.Settings, treatmentData CreateTreatmentRequestBody) (*models.Treatment, error)
UpdateTreatment(settings models.Settings, treatmentId int64, treatmentData UpdateTreatmentRequestBody) (*models.Treatment, error)
DeleteTreatment(projectId int64, treatmentId int64) error
GetDBRecord(projectId models.ID, treatmentId models.ID) (*models.Treatment, error)
RunCustomValidation(
treatmentConfig map[string]interface{},
settings models.Settings,
context ValidationContext,
operationType OperationType,
) error
}
func NewTreatmentService ¶
func NewTreatmentService( services *Services, db *gorm.DB, ) TreatmentService
type UpdateExperimentRequestBody ¶
type UpdateExperimentRequestBody struct {
Description *string `json:"description"`
EndTime time.Time `json:"end_time" validate:"required,gtfield=StartTime"`
Interval *int32 `json:"interval"`
Segment models.ExperimentSegmentRaw `json:"segment"`
StartTime time.Time `json:"start_time" validate:"required"`
Status models.ExperimentStatus `json:"status" validate:"required,oneof=inactive active"`
Treatments models.ExperimentTreatments `json:"treatments" validate:"unique=Name,dive,required,notBlank"`
Tier models.ExperimentTier `json:"tier" validate:"required,oneof=default override"`
Type models.ExperimentType `json:"type" validate:"required,oneof=A/B Switchback"`
UpdatedBy *string `json:"updated_by,omitempty"`
}
type UpdateProjectSettingsRequestBody ¶
type UpdateProjectSettingsRequestBody struct {
EnableS2idClustering *bool `json:"enable_s2id_clustering,omitempty"`
RandomizationKey string `json:"randomization_key" validate:"required,notBlank"`
Segmenters models.ProjectSegmenters `json:"segmenters" validate:"required,notBlank"`
TreatmentSchema *models.TreatmentSchema `json:"treatment_schema" validate:"omitempty"`
ValidationUrl *string `json:"validation_url" validate:"omitempty,url"`
}
type UpdateSegmentRequestBody ¶
type UpdateSegmentRequestBody struct {
Segment models.ExperimentSegmentRaw `json:"segment" validate:"required,notBlank"`
UpdatedBy *string `json:"updated_by,omitempty"`
}
type ValidationContext ¶
type ValidationContext struct {
CurrentData interface{} `json:"current_data"`
}
type ValidationService ¶
type ValidationService interface {
Validate(data interface{}) error
ValidateEntityWithExternalUrl(operation OperationType, entityType EntityType, data interface{}, context ValidationContext,
validationUrl *string) error
ValidateWithExternalUrl(reqBody []byte, validationUrl *string) error
}
func NewValidationService ¶
func NewValidationService(config config.ValidationConfig) (ValidationService, error)
NewValidationService creates a new validator
Source Files
¶
Click to show internal directories.
Click to hide internal directories.