doorman

package module
v0.0.0-...-511b00e Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2018 License: MIT Imports: 16 Imported by: 0

README

Doorman Build Status

doorman client. For the doorman server see [doorman server](https://github.com/didiercrunch/doorman server)

what it is?

This library can be use in two ways; A/B testing and feature gating.

A/B testing

The best way to explain A/B testing is via an example. Imagine that you have a button in you blog and that you want to set its colour to maximaze the number of viewers that click on it. For simplicity, let's assume the colour can be red or magenta.

A/B testing allows you to randomly select a colour for the button depending on your viewers. For example, you could deceide to show to 10% of your users the magenta button while 90% of your user will see the button red.

Then, you can collect data on your user choice (feature not include in this library) and make a data supported decision to improved you blog.

Feature gating

The best way to explain feature gating is to give an example. Imaging that you are using company A to manage the discussion section of your blog and that you want to switch to company B. You would like to make the move but you are scared that the switch will cause failure in unexpected part of your blog.

What you can do is to change graduly from company A to company B. At first, you set 1% of your viewer to see company A, if no issue occure, you move to 5% then to 10% and up to 100%.

example

There is an example at example/main.go that change randomly the colour of the background by the url path.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ONE *big.Rat = big.NewRat(1, 1)

Functions

func IsEqual

func IsEqual(f1, f2 *big.Rat) bool

Types

type Doorman

type Doorman struct {
	Id                  string     // the id of the doorman
	LastChangeTimestamp int64      // an always increasing int that represent the last time the doorman has beed updated
	Probabilities       []*big.Rat //  The probability of each cases.  The sum of probabilities needs to be one
	// contains filtered or unexported fields
}

func New

func New(id string, probabilities []*big.Rat) (*Doorman, error)

func (*Doorman) GenerateRandomProbabilityFromInteger

func (w *Doorman) GenerateRandomProbabilityFromInteger(data uint64) *big.Rat

func (*Doorman) GetCase

func (w *Doorman) GetCase(choosenRandomPosition *big.Rat) uint

func (*Doorman) GetCaseFromData

func (w *Doorman) GetCaseFromData(data ...[]byte) uint

func (*Doorman) GetCaseFromString

func (w *Doorman) GetCaseFromString(data string) uint

func (*Doorman) GetRandomCase

func (w *Doorman) GetRandomCase() uint

func (*Doorman) Hash

func (w *Doorman) Hash(data ...[]byte) uint64

func (*Doorman) Length

func (w *Doorman) Length() int

func (*Doorman) NSQSubscriber

func (w *Doorman) NSQSubscriber(NSQLookupdURl string) error

func (*Doorman) NanoMsgSubscriber

func (w *Doorman) NanoMsgSubscriber(NanoMsgUrlLookupdURl string) error

func (*Doorman) Subscriber

func (w *Doorman) Subscriber(serverUrl string) error

func (*Doorman) Update

func (w *Doorman) Update(wu *shared.DoormanUpdater) error

func (*Doorman) UpdateHard

func (w *Doorman) UpdateHard(baseURL string) error

func (*Doorman) Validate

func (w *Doorman) Validate() error

type Subscriber

type Subscriber interface {
	Subscribe(doormanId string, update shared.UpdateHandlerFunc) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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