storage

package
v5.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthEndpoint = iota
	SplitChangesEndpoint
	SegmentChangesEndpoint
	MySegmentsEndpoint
	ImpressionsBulkEndpoint
	ImpressionsBulkBeaconEndpoint
	ImpressionsCountEndpoint
	ImpressionsCountBeaconEndpoint
	EventsBulkEndpoint
	EventsBulkBeaconEndpoint
	TelemetryConfigEndpoint
	TelemetryRuntimeEndpoint
	LegacyTimeEndpoint
	LegacyTimesEndpoint
	LegacyCounterEndpoint
	LegacyCountersEndpoint
	LegacyGaugeEndpoint
)

Local telemetry constants

Variables

View Source
var ErrSegmentNotFound = errors.New("segment not found")

ErrSegmentNotFound is returned when the segment whose changes we're querying isn't cached

View Source
var ErrSummaryNotCached = errors.New("summary for requested change number not cached")

ErrSummaryNotCached is returned when a summary is not cached for a requested change number

Functions

This section is empty.

Types

type EndpointStatusCodes

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

EndpointStatusCodes keeps track of http status codes generated by the proxy endpoints

func (*EndpointStatusCodes) IncrEndpointStatus

func (e *EndpointStatusCodes) IncrEndpointStatus(endpoint int, status int)

IncrEndpointStatus increments the count of a specific status code for a specific endpoint

func (*EndpointStatusCodes) PeekEndpointStatus

func (e *EndpointStatusCodes) PeekEndpointStatus(endpoint int) map[int]int64

PeekEndpointStatus increments the count of a specific status code for a specific endpoint

type ProxyEndpointLatencies

type ProxyEndpointLatencies interface {
	PeekEndpointLatency(endpoint int) []int64
	RecordEndpointLatency(endpoint int, latency time.Duration)
}

ProxyEndpointLatencies defines an interface to access proxy server endpoint latencies numbers

type ProxyEndpointLatenciesImpl

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

ProxyEndpointLatenciesImpl keep track of the latency introudiced by each proxy endpoint

func (*ProxyEndpointLatenciesImpl) PeekEndpointLatency

func (p *ProxyEndpointLatenciesImpl) PeekEndpointLatency(endpoint int) []int64

PeekEndpointLatency records a (bucketed) latency for a specific endpoint

func (*ProxyEndpointLatenciesImpl) RecordEndpointLatency

func (p *ProxyEndpointLatenciesImpl) RecordEndpointLatency(endpoint int, latency time.Duration)

RecordEndpointLatency records a (bucketed) latency for a specific endpoint

type ProxyEndpointTelemetry

type ProxyEndpointTelemetry interface {
	ProxyTelemetryPeeker
	RecordEndpointLatency(endpoint int, latency time.Duration)
	IncrEndpointStatus(endpoint int, status int)
}

ProxyEndpointTelemetry defines the interface that endpoints use to capture latency & status codes

type ProxySegmentStorage

type ProxySegmentStorage interface {
	ChangesSince(name string, since int64) (*dtos.SegmentChangesDTO, error)
	SegmentsFor(key string) ([]string, error)
	CountRemovedKeys(segmentName string) int
}

ProxySegmentStorage defines the set of methods that are required for the proxy server to respond to resquests from sdk clients

type ProxySegmentStorageImpl

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

ProxySegmentStorageImpl implements the ProxySegmentStorage interface

func NewProxySegmentStorage

func NewProxySegmentStorage(db persistent.DBWrapper, logger logging.LoggerInterface, restoreFromBackup bool) *ProxySegmentStorageImpl

NewProxySegmentStorage for proxy

func (*ProxySegmentStorageImpl) ChangeNumber

func (s *ProxySegmentStorageImpl) ChangeNumber(segment string) (int64, error)

ChangeNumber storage

func (*ProxySegmentStorageImpl) ChangesSince

func (s *ProxySegmentStorageImpl) ChangesSince(name string, since int64) (*dtos.SegmentChangesDTO, error)

ChangesSince returns the `segmentChanges` like payload to from a certain CN to the last snapshot This method has one drawback. ALL the historically removed keys are always returned as part of the `removed` array, regardless whether the `since` parameter is old enough to require such removal or not. We should eventually see if it's worth taking an approach similar to the one in splits or not

func (*ProxySegmentStorageImpl) CountRemovedKeys

func (s *ProxySegmentStorageImpl) CountRemovedKeys(segmentName string) int

CountRemovedKeys method

func (*ProxySegmentStorageImpl) Keys

func (s *ProxySegmentStorageImpl) Keys(segmentName string) *set.ThreadUnsafeSet

Keys method

func (*ProxySegmentStorageImpl) SegmentContainsKey

func (s *ProxySegmentStorageImpl) SegmentContainsKey(segmentName string, key string) (bool, error)

SegmentContainsKey method

func (*ProxySegmentStorageImpl) SegmentKeysCount

func (s *ProxySegmentStorageImpl) SegmentKeysCount() int64

SegmentKeysCount returns 0

func (*ProxySegmentStorageImpl) SegmentsFor

func (s *ProxySegmentStorageImpl) SegmentsFor(key string) ([]string, error)

SegmentsFor returns the list of segments a key belongs to

func (*ProxySegmentStorageImpl) SetChangeNumber

func (s *ProxySegmentStorageImpl) SetChangeNumber(segment string, changeNumber int64) error

SetChangeNumber method

func (*ProxySegmentStorageImpl) Update

func (s *ProxySegmentStorageImpl) Update(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet, changeNumber int64) error

Update method

type ProxySplitStorage

type ProxySplitStorage interface {
	ChangesSince(since int64) (*dtos.SplitChangesDTO, error)
	RegisterOlderCn(payload *dtos.SplitChangesDTO)
}

ProxySplitStorage defines the interface of a storage that can be used for serving splitChanges payloads for different requested `since` parameters

type ProxySplitStorageImpl

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

ProxySplitStorageImpl implements the ProxySplitStorage interface and the SplitProducer interface

func NewProxySplitStorage

func NewProxySplitStorage(db persistent.DBWrapper, logger logging.LoggerInterface, restoreBackup bool) *ProxySplitStorageImpl

NewProxySplitStorage instantiates a new proxy storage that wraps an in-memory snapshot of the last known, flag configuration, a changes summaries containing recipes to update SDKs with different CNs, and a persistent storage for snapshot purposes

func (*ProxySplitStorageImpl) All

func (p *ProxySplitStorageImpl) All() []dtos.SplitDTO

All call is forwarded to the snapshot

func (*ProxySplitStorageImpl) ChangeNumber

func (p *ProxySplitStorageImpl) ChangeNumber() (int64, error)

ChangeNumber returns the current change number

func (*ProxySplitStorageImpl) ChangesSince

func (p *ProxySplitStorageImpl) ChangesSince(since int64) (*dtos.SplitChangesDTO, error)

ChangesSince builds a SplitChanges payload to from `since` to the latest known CN

func (*ProxySplitStorageImpl) FetchMany

func (p *ProxySplitStorageImpl) FetchMany(names []string) map[string]*dtos.SplitDTO

FetchMany call is forwarded to the snapshot

func (*ProxySplitStorageImpl) KillLocally

func (p *ProxySplitStorageImpl) KillLocally(splitName string, defaultTreatment string, changeNumber int64)

KillLocally marks a split as killed in the current storage

func (*ProxySplitStorageImpl) RegisterOlderCn

func (p *ProxySplitStorageImpl) RegisterOlderCn(payload *dtos.SplitChangesDTO)

RegisterOlderCn registers payload associated to a fetch request for an old `since` for which we don't have a recipe

func (*ProxySplitStorageImpl) Remove

func (p *ProxySplitStorageImpl) Remove(name string)

Remove deletes a split by name

func (*ProxySplitStorageImpl) SegmentNames

func (p *ProxySplitStorageImpl) SegmentNames() *set.ThreadUnsafeSet

SegmentNames call is forwarded to the snapshot

func (*ProxySplitStorageImpl) SetChangeNumber

func (p *ProxySplitStorageImpl) SetChangeNumber(cn int64) error

SetChangeNumber updates the change number

func (*ProxySplitStorageImpl) Split

func (p *ProxySplitStorageImpl) Split(name string) *dtos.SplitDTO

Split call is forwarded to the snapshot

func (*ProxySplitStorageImpl) SplitNames

func (p *ProxySplitStorageImpl) SplitNames() []string

SplitNames call is forwarded to the snapshot

func (*ProxySplitStorageImpl) TrafficTypeExists

func (p *ProxySplitStorageImpl) TrafficTypeExists(tt string) bool

TrafficTypeExists call is forwarded to the snapshot

func (*ProxySplitStorageImpl) Update

func (p *ProxySplitStorageImpl) Update(toAdd []dtos.SplitDTO, toRemove []dtos.SplitDTO, changeNumber int64)

Update the storage atomically

type ProxyTelemetryFacade

type ProxyTelemetryFacade interface {
	storage.TelemetryStorage
	ProxyEndpointTelemetry
}

ProxyTelemetryFacade defines the set of methods required to accept local telemetry as well as runtime telemetry

type ProxyTelemetryFacadeImpl

type ProxyTelemetryFacadeImpl struct {
	ProxyEndpointLatenciesImpl
	EndpointStatusCodes
	*inmemory.TelemetryStorage
}

ProxyTelemetryFacadeImpl exposes local telemetry functionality

func NewProxyTelemetryFacade

func NewProxyTelemetryFacade() *ProxyTelemetryFacadeImpl

NewProxyTelemetryFacade instantiates a local telemetry facade

type ProxyTelemetryPeeker

type ProxyTelemetryPeeker interface {
	PeekEndpointLatency(resource int) []int64
	PeekEndpointStatus(resource int) map[int]int64
}

ProxyTelemetryPeeker is able to peek at locally captured metrics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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