featurelab

package
v0.0.0-...-dabd34d Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidTreatmentAllocation = errors.New("invalid treatment allocation")
View Source
var FeatureOff = TreatmentAssignment{}

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(featureLabHost string) *Client

func (*Client) FetchFeature

func (c *Client) FetchFeature(app string, featureName string) (Feature, *Error)

func (*Client) FetchFeatures

func (c *Client) FetchFeatures(app string) ([]Feature, *Error)

func (*Client) GetTreatment

func (c *Client) GetTreatment(app string, feature string, criteria string) (TreatmentAssignment, *Error)

type Error

type Error struct {
	Code    ErrorType `json:"code"`
	Message string    `json:"message"`
}

func NewError

func NewError(code ErrorType, message string) *Error

func (*Error) Error

func (e *Error) Error() string

type ErrorType

type ErrorType uint32
const (
	// Error codes returned by API, these are different from the HTTP status codes
	ErrBadRequest          ErrorType = 400
	ErrNotFound            ErrorType = 404
	ErrInternalServerError ErrorType = 500
	ErrInvalidTreatment    ErrorType = 5000
)

type Feature

type Feature struct {
	App         string              `json:"app"`
	Name        string              `json:"name"`
	Allocations []FeatureAllocation `json:"allocations"`
}

func NewFeature

func NewFeature(app string, name string, allocations []FeatureAllocation) Feature

func (*Feature) TotalAllocationWeight

func (f *Feature) TotalAllocationWeight() uint32

type FeatureAllocation

type FeatureAllocation struct {
	Treatment string `json:"treatment"`
	Weight    uint32 `json:"weight"`
}

func NewFeatureAllocation

func NewFeatureAllocation(treatment string, weight uint32) FeatureAllocation

type FeatureLab

type FeatureLab interface {
	GetTreatment(app string, featureName string, criteria string) (TreatmentAssignment, *Error)
	FetchFeatures(app string) ([]Feature, *Error)
	FetchFeature(app string, featureName string) (Feature, *Error)
}

func NewFeatureLabClient

func NewFeatureLabClient(featureLabHost string) FeatureLab

NewFeatureLabClient creates an instance of FeatureLab which can make calls to the Feature Lab backend service.

func NewFeatureLabDaemonClient

func NewFeatureLabDaemonClient(port uint, apps ...string) (FeatureLab, *grpc.ClientConn, error)

type FeatureLabClient

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

func (*FeatureLabClient) FetchFeature

func (f *FeatureLabClient) FetchFeature(app string, featureName string) (Feature, *Error)

FetchFeature fetches the Feature information of a Feature from the Feature Lab backend service.

func (*FeatureLabClient) FetchFeatures

func (f *FeatureLabClient) FetchFeatures(app string) ([]Feature, *Error)

FetchFeatures fetches all features from the Feature Lab backend service.

func (*FeatureLabClient) GetTreatment

func (f *FeatureLabClient) GetTreatment(app string, featureName string, criteria string) (TreatmentAssignment, *Error)

GetTreatment fetches the treatment that is assigned for a criteria in a particular Feature.

type FeatureLabDaemonClient

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

func (*FeatureLabDaemonClient) FetchFeature

func (f *FeatureLabDaemonClient) FetchFeature(app string, featureName string) (Feature, *Error)

FetchFeature fetches the Feature information of a Feature from the Feature Lab backend service.

func (*FeatureLabDaemonClient) FetchFeatures

func (f *FeatureLabDaemonClient) FetchFeatures(app string) ([]Feature, *Error)

FetchFeatures fetches all features from the Feature Lab backend service.

func (*FeatureLabDaemonClient) GetTreatment

func (f *FeatureLabDaemonClient) GetTreatment(app string, featureName string, criteria string) (TreatmentAssignment, *Error)

GetTreatment fetches the treatment that is assigned for a criteria in a particular Feature.

type TreatmentAssigner

type TreatmentAssigner struct {
}

func NewTreatmentAssigner

func NewTreatmentAssigner() TreatmentAssigner

func (*TreatmentAssigner) GetTreatmentAssignment

func (ta *TreatmentAssigner) GetTreatmentAssignment(feature Feature, criteria string) (TreatmentAssignment, error)

type TreatmentAssignment

type TreatmentAssignment struct {
	Treatment string `json:"treatment"`
}

Jump to

Keyboard shortcuts

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