Documentation ¶
Index ¶
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 )
const TypeCastingErrorTmpl = "invalid type of variable (%s) was provided for %s segmenter; expected %s"
Variables ¶
var Runners = make(map[string]Factory)
Runners contain all the registered segmenter runners by name.
Functions ¶
func Register ¶
Register a segmenter runner 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 runner is implemented. The name of the segmenter runners should be unique across all implementations. Registering multiple segmenter runners with the same name will return an error.
Types ¶
type BaseRunner ¶
type BaseRunner struct {
// contains filtered or unexported fields
}
func NewBaseRunner ¶
func NewBaseRunner(s *SegmenterConfig) *BaseRunner
func (*BaseRunner) GetName ¶
func (r *BaseRunner) GetName() string
func (*BaseRunner) Transform ¶
func (r *BaseRunner) Transform( segmenter string, requestValues map[string]interface{}, experimentVariables []string, ) ([]*_segmenters.SegmenterValue, error)
type Factory ¶
type Factory func(config json.RawMessage) (Runner, error)
Factory creates a segmenter runner from the provided config.
Config is a raw encoded JSON value. The segmenter runner implementation for each segmenter should provide a schema and example of the JSON value to explain the usage.
type Runner ¶
type Runner interface { GetName() string Transform(name string, requestValues map[string]interface{}, experimentVariables []string) ([]*_segmenters.SegmenterValue, error) }
func Get ¶
func Get(name string, config json.RawMessage) (Runner, error)
Get a segmenter runner that has been registered.
The segmenter runner will be initialized using the registered factory function with the provided config. Retrieving a segmenter runner that is not yet registered will return an error.
func NewDaysOfWeekSegmenter ¶
func NewDaysOfWeekSegmenter(_ json.RawMessage) (Runner, error)
func NewHoursOfDaySegmenter ¶
func NewHoursOfDaySegmenter(_ json.RawMessage) (Runner, error)
func NewS2IDRunner ¶
func NewS2IDRunner(configData json.RawMessage) (Runner, error)
type S2IDSegmenterConfig ¶
type SegmenterConfig ¶
type SegmenterConfig struct { Name string Type *_segmenters.SegmenterValueType }