Documentation ¶
Index ¶
- Constants
- Variables
- func ProtobufSegmenterConfigToOpenAPISegmenterConfig(segmenterConfiguration *_segmenters.SegmenterConfiguration) (*schema.Segmenter, error)
- func Register(name string, factory Factory) error
- func ToProtoValues(segments map[string]interface{}, ...) (map[string]*_segmenters.ListSegmenterValue, error)
- type BaseSegmenter
- func (s *BaseSegmenter) GetConfiguration() (*_segmenters.SegmenterConfiguration, error)
- func (s *BaseSegmenter) GetExperimentVariables() *_segmenters.ListExperimentVariables
- func (s *BaseSegmenter) GetName() string
- func (s *BaseSegmenter) GetType() _segmenters.SegmenterValueType
- func (s *BaseSegmenter) IsValidType(inputValues []*_segmenters.SegmenterValue) bool
- func (s *BaseSegmenter) ValidateSegmenterAndConstraints(segment map[string]*_segmenters.ListSegmenterValue) error
- type Factory
- type S2IDSegmenterConfig
- type Segmenter
Constants ¶
const ( // MinS2CellLevel is the permissible minimum value for S2 Cell level MinS2CellLevel = 0 // MaxS2CellLevel is the permissible maximum value for S2 Cell level MaxS2CellLevel = 30 )
Variables ¶
var Segmenters = make(map[string]Factory)
segmenters contain all the registered experiment segmenters by name.
Functions ¶
func ProtobufSegmenterConfigToOpenAPISegmenterConfig ¶
func ProtobufSegmenterConfigToOpenAPISegmenterConfig(segmenterConfiguration *_segmenters.SegmenterConfiguration) (*schema.Segmenter, error)
func Register ¶
Register an experiment segmenter with the provided name and factory function.
For registration to be properly recorded, Register function should be called in the init phase of the Go execution. The init function is usually defined in the package where the segmenter is implemented. The name of the experiment segmenters should be unique across all implementations. Registering multiple experiment segmenters with the same name will return an error.
func ToProtoValues ¶
func ToProtoValues( segments map[string]interface{}, segmentersType map[string]schema.SegmenterType, ) (map[string]*_segmenters.ListSegmenterValue, error)
Types ¶
type BaseSegmenter ¶
type BaseSegmenter struct {
// contains filtered or unexported fields
}
func NewBaseSegmenter ¶
func NewBaseSegmenter(s *_segmenters.SegmenterConfiguration) *BaseSegmenter
func (*BaseSegmenter) GetConfiguration ¶
func (s *BaseSegmenter) GetConfiguration() (*_segmenters.SegmenterConfiguration, error)
func (*BaseSegmenter) GetExperimentVariables ¶
func (s *BaseSegmenter) GetExperimentVariables() *_segmenters.ListExperimentVariables
func (*BaseSegmenter) GetName ¶
func (s *BaseSegmenter) GetName() string
func (*BaseSegmenter) GetType ¶
func (s *BaseSegmenter) GetType() _segmenters.SegmenterValueType
func (*BaseSegmenter) IsValidType ¶
func (s *BaseSegmenter) IsValidType(inputValues []*_segmenters.SegmenterValue) bool
IsValidType checks that the input values for the segmenter are of the configured type
func (*BaseSegmenter) ValidateSegmenterAndConstraints ¶
func (s *BaseSegmenter) ValidateSegmenterAndConstraints(segment map[string]*_segmenters.ListSegmenterValue) error
ValidateSegmenterAndConstraints validates the current segmenter's values, taking into account the configuration of the whole segment.
type Factory ¶
type Factory func(config json.RawMessage) (Segmenter, error)
Factory creates a segmenter manager from the provided config.
Config is a raw encoded JSON value. The segmenter manager implementation for each segmenter should provide a schema and example of the JSON value to explain the usage.
type S2IDSegmenterConfig ¶
type Segmenter ¶
type Segmenter interface { GetName() string GetType() _segmenters.SegmenterValueType GetConfiguration() (*_segmenters.SegmenterConfiguration, error) GetExperimentVariables() *_segmenters.ListExperimentVariables IsValidType(inputValues []*_segmenters.SegmenterValue) bool ValidateSegmenterAndConstraints(segment map[string]*_segmenters.ListSegmenterValue) error }
func Get ¶
func Get(name string, config json.RawMessage) (Segmenter, error)
Get an experiment segmenter that has been registered.
The segmenter will be initialized using the registered factory function with the provided config. Retrieving an experiment segmenter that is not yet registered will return an error.
func NewDaysOfWeekSegmenter ¶
func NewDaysOfWeekSegmenter(_ json.RawMessage) (Segmenter, error)
func NewHoursOfDaySegmenter ¶
func NewHoursOfDaySegmenter(_ json.RawMessage) (Segmenter, error)
func NewS2IDSegmenter ¶
func NewS2IDSegmenter(configData json.RawMessage) (Segmenter, error)