optimized

package
v5.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownChangeNumber = errors.New("Unknown change number")

ErrUnknownChangeNumber is returned when trying to fetch a recipe for a change number not present in cache

Functions

func BuildArchivedSplitsFor

func BuildArchivedSplitsFor(nameToTrafficType map[string]string) []dtos.SplitDTO

BuildArchivedSplitsFor takes a mapping of split name -> traffic type name, and build fake "ARCHIVED" splits to return to the sdk upon a splitChanges request now that we no longer store the full body of archived splits

Types

type ChangeSummary

type ChangeSummary struct {
	Updated map[string]string // split name -> trafficType
	Removed map[string]string // split name -> trafficType
}

ChangeSummary represents a set of changes from/in a specific point in time

type MySegmentsCache

type MySegmentsCache interface {
	Update(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet) error
	SegmentsForUser(key string) []string
	KeyCount() int
}

MySegmentsCache defines the interface for a per-user optimized segment storage

type MySegmentsCacheImpl

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

MySegmentsCacheImpl implements the MySegmentsCache interface

func NewMySegmentsCache

func NewMySegmentsCache() *MySegmentsCacheImpl

NewMySegmentsCache constructs a new MySegments cache

func (*MySegmentsCacheImpl) KeyCount

func (m *MySegmentsCacheImpl) KeyCount() int

KeyCount retuns the amount of keys who belong to at least one segment

func (*MySegmentsCacheImpl) SegmentsForUser

func (m *MySegmentsCacheImpl) SegmentsForUser(key string) []string

SegmentsForUser returns the list of segments a certain user belongs to

func (*MySegmentsCacheImpl) Update

func (m *MySegmentsCacheImpl) Update(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet) error

Update adds and removes segments to keys

type SplitChangesSummaries

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

SplitChangesSummaries keeps a set of recipes that allow an sdk to fetch from any known changeNumber up to the latest snapshot.

func NewSplitChangesSummaries

func NewSplitChangesSummaries(maxRecipes int) *SplitChangesSummaries

NewSplitChangesSummaries constructs a SplitChangesSummaries component

func (*SplitChangesSummaries) AddChanges

func (s *SplitChangesSummaries) AddChanges(added []dtos.SplitDTO, removed []dtos.SplitDTO, cn int64)

AddChanges registers a new set of changes and updates all the recipes accordingly

func (*SplitChangesSummaries) AddOlderChange

func (s *SplitChangesSummaries) AddOlderChange(added []dtos.SplitDTO, removed []dtos.SplitDTO, cn int64)

AddOlderChange is used to add a change older than the oldest one currently stored (when the sync started) so that it can be used to serve SDKs stuck on an older CN

func (*SplitChangesSummaries) FetchSince

func (s *SplitChangesSummaries) FetchSince(since int64) (*ChangeSummary, int64, error)

FetchSince returns a recipe explaining how to build a /splitChanges payload to serve an sdk which is currently on changeNumber `since`. It will contain the list of splits that need to be updated, and those that need to be deleted

type SplitMinimalView

type SplitMinimalView struct {
	Name        string
	TrafficType string
}

SplitMinimalView is a subset of split properties needed by an sdk to remove a split from it's local cache

Jump to

Keyboard shortcuts

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