strategy

package
v5.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugImpl

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

DebugImpl struct for debug impression mode strategy.

func (*DebugImpl) Apply

func (s *DebugImpl) Apply(impressions []dtos.Impression) ([]dtos.Impression, []dtos.Impression)

Apply calculate the pt and return the impression.

func (*DebugImpl) ApplySingle

func (s *DebugImpl) ApplySingle(impression *dtos.Impression) bool

ApplySingle description

type ImpressionHasher

type ImpressionHasher interface {
	Process(featureName string, impression *dtos.Impression) (int64, error)
}

ImpressionHasher interface

type ImpressionHasherImpl

type ImpressionHasherImpl struct{}

ImpressionHasherImpl implements the hasher interface, mapping certain fields to an int64

func (*ImpressionHasherImpl) Process

func (h *ImpressionHasherImpl) Process(featureName string, impression *dtos.Impression) (int64, error)

Process an impression and return the 64 LSBs of a murmur3-128 digest

type ImpressionObserver

type ImpressionObserver interface {
	TestAndSet(featureName string, impression *dtos.Impression) (int64, error)
}

ImpressionObserver is used to check wether an impression has been previously seen

type ImpressionObserverImpl

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

ImpressionObserverImpl is an implementation of the ImpressionObserver interface

func NewImpressionObserver

func NewImpressionObserver(size int) (*ImpressionObserverImpl, error)

NewImpressionObserver constructs a new ImpressionObserver

func (*ImpressionObserverImpl) TestAndSet

func (o *ImpressionObserverImpl) TestAndSet(featureName string, impression *dtos.Impression) (int64, error)

TestAndSet hashes the impression, updates the cache and returns the previous value

type ImpressionObserverNoOp

type ImpressionObserverNoOp struct{}

ImpressionObserverNoOp is an implementation of the ImpressionObserver interface

func (*ImpressionObserverNoOp) TestAndSet

func (o *ImpressionObserverNoOp) TestAndSet(featureName string, impression *dtos.Impression) (int64, error)

TestAndSet that does nothing

type ImpressionsCounter

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

ImpressionsCounter struct for storing generated impressions counts

func NewImpressionsCounter

func NewImpressionsCounter() *ImpressionsCounter

NewImpressionsCounter creates new ImpressionsCounter

func (*ImpressionsCounter) Inc

func (i *ImpressionsCounter) Inc(splitName string, timeFrame int64, amount int64)

Inc increments the quantity of impressions with the passed splitName and timeFrame

func (*ImpressionsCounter) PopAll

func (i *ImpressionsCounter) PopAll() map[Key]int64

PopAll returns all the elements stored in the cache and resets the cache

func (*ImpressionsCounter) Size

func (i *ImpressionsCounter) Size() int

Size returns how many keys are stored in cache

type Key

type Key struct {
	FeatureName string
	TimeFrame   int64
}

Key struct for mapping each key to an amount

type NoneImpl

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

NoneImpl struct for none impression mode strategy.

func (*NoneImpl) Apply

func (s *NoneImpl) Apply(impressions []dtos.Impression) ([]dtos.Impression, []dtos.Impression)

Apply track the total amount of evaluations and the unique keys.

func (*NoneImpl) ApplySingle

func (s *NoneImpl) ApplySingle(impression *dtos.Impression) bool

ApplySingle description

type OptimizedImpl

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

OptimizedImpl struct for optimized impression mode strategy.

func (*OptimizedImpl) Apply

func (s *OptimizedImpl) Apply(impressions []dtos.Impression) ([]dtos.Impression, []dtos.Impression)

Apply track the total amount of evaluations and deduplicate the impressions.

func (*OptimizedImpl) ApplySingle

func (s *OptimizedImpl) ApplySingle(impression *dtos.Impression) bool

ApplySingle track the total amount of evaluations and deduplicate the impressions.

type ProcessStrategyInterface

type ProcessStrategyInterface interface {
	Apply(impressions []dtos.Impression) ([]dtos.Impression, []dtos.Impression)
	ApplySingle(impression *dtos.Impression) bool
}

ProcessStrategyInterface interface

func NewDebugImpl

func NewDebugImpl(impressionObserver ImpressionObserver, listenerEnabled bool) ProcessStrategyInterface

NewDebugImpl creates new DebugImpl.

func NewNoneImpl

func NewNoneImpl(impressionCounter *ImpressionsCounter, uniqueKeysTracker UniqueKeysTracker, listenerEnabled bool) ProcessStrategyInterface

NewNoneImpl creates new NoneImpl.

func NewOptimizedImpl

func NewOptimizedImpl(impressionObserver ImpressionObserver, impressionCounter *ImpressionsCounter, runtimeTelemetry storage.TelemetryRuntimeProducer, listenerEnabled bool) ProcessStrategyInterface

NewOptimizedImpl creates new OptimizedImpl.

type UniqueKeysTracker

type UniqueKeysTracker interface {
	Track(featureName string, key string) bool
	PopAll() dtos.Uniques
}

UniqueKeysTracker interface

func NewUniqueKeysTracker

func NewUniqueKeysTracker(f storage.Filter) UniqueKeysTracker

NewUniqueKeysTracker create new implementation

type UniqueKeysTrackerImpl

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

UniqueKeysTrackerImpl description

func (*UniqueKeysTrackerImpl) PopAll

func (t *UniqueKeysTrackerImpl) PopAll() dtos.Uniques

PopAll returns all the elements stored in the cache and resets the cache

func (*UniqueKeysTrackerImpl) Track

func (t *UniqueKeysTrackerImpl) Track(featureName string, key string) bool

Track description

Jump to

Keyboard shortcuts

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