featurelabd

package
v0.0.0-...-e6609da Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFeatureLabService

func NewFeatureLabService(featureLabClient featurelab.FeatureLab) pb.FeatureLabServer

Types

type CacheableFeatureLabClient

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

func NewCacheableFeatureLabClient

func NewCacheableFeatureLabClient(featureLabHost string, ttl, cleanUpInterval time.Duration) *CacheableFeatureLabClient

func (*CacheableFeatureLabClient) FetchFeature

func (f *CacheableFeatureLabClient) FetchFeature(app string, featureName string) (featurelab.Feature, *featurelab.Error)

FetchFeature fetches the Feature information of a Feature from the Feature Lab backend service and stores it in cache, overwriting any value that already exists in the cache with the same Feature Treatment.

func (*CacheableFeatureLabClient) FetchFeatures

func (f *CacheableFeatureLabClient) FetchFeatures(app string) ([]featurelab.Feature, *featurelab.Error)

FetchFeatures fetches all features from the Feature Lab backend service and stores them in cache, overwriting any values that already exist in the cache with the same Feature names.

func (*CacheableFeatureLabClient) GetTreatment

func (f *CacheableFeatureLabClient) GetTreatment(app string, featureName string, criteria string) (featurelab.TreatmentAssignment, *featurelab.Error)

GetTreatment calculates the treatment that is assigned for a criteria in a particular Feature stored in the cache. If the Feature is not in the cache, then featurelab.FeatureOff is returned. This method won't make calls to the backend service, it will only operate on features stored in cache. To force a cache update, you must call FetchFeatures (to cache all features) or FetchFeature (for a specific Feature).

func (*CacheableFeatureLabClient) UpdateCache

func (f *CacheableFeatureLabClient) UpdateCache() *featurelab.Error

type FeatureCache

type FeatureCache interface {
	GetFeature(app, name string) (featurelab.Feature, bool)
	PutFeature(app, name string, feature featurelab.Feature)
	PutFeatures(features []featurelab.Feature)
}

func NewDefaultFeatureCache

func NewDefaultFeatureCache(ttl time.Duration, cleanUpInterval time.Duration) FeatureCache

type FeatureLabService

type FeatureLabService struct {
	pb.FeatureLabServer
	// contains filtered or unexported fields
}

func (*FeatureLabService) FetchFeature

func (fls *FeatureLabService) FetchFeature(ctx context.Context, fetchFeatureRequest *pb.FetchFeatureRequest) (*pb.FetchFeatureResponse, error)

func (*FeatureLabService) FetchFeatures

func (fls *FeatureLabService) FetchFeatures(ctx context.Context, fetchFeaturesRequest *pb.FetchFeaturesRequest) (*pb.FetchFeaturesResponse, error)

func (*FeatureLabService) GetTreatment

func (fls *FeatureLabService) GetTreatment(ctx context.Context, getTreatmentRequest *pb.GetTreatmentRequest) (*pb.GetTreatmentResponse, error)

Jump to

Keyboard shortcuts

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