rocket_bucket

package
v0.0.0-...-2d98901 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(format string, args ...interface{})

func Fatal

func Fatal(format string, args ...interface{})

func Info

func Info(format string, args ...interface{})

Types

type AssignBucketsRequestHandler

type AssignBucketsRequestHandler struct {
	UserID   string
	Selector *Selector
}

func (*AssignBucketsRequestHandler) Handle

func (p *AssignBucketsRequestHandler) Handle() (map[string]interface{}, int)

type Bucket

type Bucket struct {
	Name                  string             `json:"name"`
	Percent               int                `json:"percent"`
	Data                  []ConfigBucketData `json:"data,omitempty"`
	CumulativeProbability uint32             `json:"-"`
}

type BucketRequestHandler

type BucketRequestHandler interface {
	Handle() (map[string]interface{}, int)
}

type Buckets

type Buckets []Bucket

func (Buckets) Len

func (slice Buckets) Len() int

func (Buckets) Less

func (slice Buckets) Less(i, j int) bool

func (Buckets) Swap

func (slice Buckets) Swap(i, j int)

type Config

type Config struct {
	Server               ServerConfig
	Experiments          Experiments
	TemporaryServer      ServerConfig `json:"server"`
	TemporaryExperiments Experiments  `json:"experiments"`
	LastParsed           time.Time
}

func (*Config) IsAPIKeyMandatory

func (c *Config) IsAPIKeyMandatory() bool

func (*Config) IsValidAPIKey

func (c *Config) IsValidAPIKey(possibleKey string) bool

func (*Config) Parse

func (c *Config) Parse(rawJson []byte)

type ConfigBucketData

type ConfigBucketData struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type DumpBucketsRequestHandler

type DumpBucketsRequestHandler struct {
	Config *Config
}

func (*DumpBucketsRequestHandler) Handle

func (p *DumpBucketsRequestHandler) Handle() (map[string]interface{}, int)

type Experiment

type Experiment struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	IsEnabled   bool    `json:"enabled"`
	Buckets     Buckets `json:"buckets"`
	Hash        uint32  `json:"-"`
}

type Experiments

type Experiments []Experiment

type SelectedBucket

type SelectedBucket struct {
	Name string             `json:"name"`
	Data []ConfigBucketData `json:"data,omitempty"`
}

type SelectedExperiment

type SelectedExperiment struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Bucket      SelectedBucket `json:"bucket"`
}

type Selector

type Selector struct {
	Experiments *Experiments
}

func (*Selector) AssignBuckets

func (s *Selector) AssignBuckets(userID string) []SelectedExperiment

type Server

type Server struct {
	Config   *Config
	Selector *Selector
}

func (*Server) HandleBucketAssignment

func (s *Server) HandleBucketAssignment(w http.ResponseWriter, r *http.Request)

func (*Server) HandleBucketDump

func (s *Server) HandleBucketDump(w http.ResponseWriter, r *http.Request)

func (*Server) Run

func (s *Server) Run()

type ServerConfig

type ServerConfig struct {
	Port          int      `json:"port"`
	URL           string   `json:"url"`
	CacheMaxAge   int      `json:"cache_max_age"`
	APIKeys       []string `json:"api_keys"`
	APIKeyMap     map[string]bool
	BucketDumpURL string
}

type Session

type Session struct {
	StartTime                   time.Time
	RemoteAddr                  string
	ResponseCode                int
	ResponseBody                []byte
	PrivateLoggedResponseString string
	APIKey                      string
	// contains filtered or unexported fields
}

func (*Session) Process

func (s *Session) Process(bucketHandler BucketRequestHandler, writer http.ResponseWriter, request *http.Request, config *Config)

Jump to

Keyboard shortcuts

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