gates

package
v0.0.0-...-57a5977 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGroup

func RegisterGroup(name string, f GroupFunc)

RegisterGroup associates group names with functions.

Types

type ActorGate

type ActorGate struct {
	// contains filtered or unexported fields
}

ActorGate is a gate to check if a feature is open for an actor.

func NewActorGate

func NewActorGate(set Set) ActorGate

NewActorGate initializes an ActorGate with a set of ids.

func (ActorGate) IsOpen

func (g ActorGate) IsOpen(f feature.Feature, a actor.Actor) bool

IsOpen check if the gate is open for an feature and an actor. It uses the actor set to know whether the gate is open or not.

func (ActorGate) Key

func (ActorGate) Key() GateKey

Key returns the GateKey for an ActorGate gate.

func (ActorGate) SetValue

func (g ActorGate) SetValue() Set

SetValue returns the set of actors for which the gate is open. This satisfies the SetGateType interface.

type BoolGate

type BoolGate struct {
	// contains filtered or unexported fields
}

BoolGate is a gate that's open when its value is true.

func NewBoolGate

func NewBoolGate(value bool) BoolGate

NewBoolGate initializes a new BoolGate with a value.

func (BoolGate) BoolValue

func (g BoolGate) BoolValue() bool

BoolValue returns the boolean value This satisfies the BoolGateType interface.

func (BoolGate) IsOpen

func (g BoolGate) IsOpen(f feature.Feature, a actor.Actor) bool

IsOpen check if the gate is open for an feature and an actor. It returns the value of the gate.

func (BoolGate) Key

func (BoolGate) Key() GateKey

Key returns the GateKey for a BoolGate gate.

type BoolGateType

type BoolGateType interface {
	BoolValue() bool
}

BoolGateType represents a gate that uses boolean values.

type Gate

type Gate interface {
	Key() GateKey
	IsOpen(f feature.Feature, a actor.Actor) bool
}

Gate represents a feature constraint.

type GateKey

type GateKey string

GateKey is the type for gate keys.

const (

	// BoolGateKey is the key for a BoolGate
	BoolGateKey GateKey = "boolean"
	// ActorGateKey is the key for an ActorGate
	ActorGateKey GateKey = "actors"
	// GroupGateKey is the key for a GroupGateKey
	GroupGateKey GateKey = "groups"
	// PercentageOfActorsGateKey is the key for a PercentageOfActorsGate
	PercentageOfActorsGateKey GateKey = "percentage_of_actors"
	// PercentageOfTimeGateKey is the key for a PercentageOfTimeGate
	PercentageOfTimeGateKey GateKey = "percentage_of_time"
)

type GroupFunc

type GroupFunc func(actor.Actor) bool

GroupFunc is a function type to check if a feature is enabled for a group or not.

type GroupGate

type GroupGate struct {
	// contains filtered or unexported fields
}

GroupGate is a gate that checks if an actor is in a group or not. It uses registered GroupFunc functions for those checks.

func NewGroupGate

func NewGroupGate(set Set) GroupGate

NewGroupGate initializes a GroupGate with a set of group names.

func (GroupGate) IsOpen

func (g GroupGate) IsOpen(f feature.Feature, a actor.Actor) bool

IsOpen check if the gate is open for an feature and an actor. It uses the registered GroupFunc to know if the gate is open or not.

func (GroupGate) Key

func (GroupGate) Key() GateKey

Key returns the GateKey for an GroupGate gate.

func (GroupGate) SetValue

func (g GroupGate) SetValue() Set

SetValue returns the set of groups for which the gate is open. This satisfies the SetGateType interface.

type IntGateType

type IntGateType interface {
	IntValue() int
}

IntGateType represents a gate that uses int values.

type PercentageOfActorsGate

type PercentageOfActorsGate struct {
	// contains filtered or unexported fields
}

PercentageOfActorsGate is a gate that's open only for a percentage of the actors checked. The percentage can be any value between 0 and 100.

func NewPercentageOfActorsGate

func NewPercentageOfActorsGate(percentage int) PercentageOfActorsGate

NewPercentageOfActorsGate initializes a PercentageOfActorsGate gate with a given percentage.

func (PercentageOfActorsGate) IntValue

func (g PercentageOfActorsGate) IntValue() int

IntValue returns the gate's percentage as an int. This satisfies the IntGateType interface.

func (PercentageOfActorsGate) IsOpen

IsOpen check if the gate is open for an feature and an actor. It calculates the likeliness of being open by its percentage.

func (PercentageOfActorsGate) Key

Key returns the GateKey for a PercentageOfActorsGate gate.

type PercentageOfTimeGate

type PercentageOfTimeGate struct {
	// contains filtered or unexported fields
}

PercentageOfTimeGate is a gate that's open only a percentage of times. The percentage can be any value between 0 and 100.

func NewPercentageOfTimeGate

func NewPercentageOfTimeGate(percentage int) PercentageOfTimeGate

NewPercentageOfTimeGate initializes a PercentageOfTimeGate gate with a given percentage.

func (PercentageOfTimeGate) IntValue

func (g PercentageOfTimeGate) IntValue() int

IntValue returns the gate's percentage as an int. This satisfies the IntGateType interface.

func (PercentageOfTimeGate) IsOpen

IsOpen check if the gate is open for an feature and an actor. It calculates the likeliness of being open by its percentage.

func (PercentageOfTimeGate) Key

Key returns the GateKey for a PercentageOfTimeGate gate.

type Set

type Set map[string]string

Set is a key set.

func NewSet

func NewSet(values ...string) Set

type SetGateType

type SetGateType interface {
	SetValue() Set
}

SetGateType represents a gate that uses set values.

Jump to

Keyboard shortcuts

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