storage

package
v5.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 17 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
	TelemetryRuntimeBeaconEndpoint
	TelemetryKeysClientSideEndpoint
	TelemetryKeysClientSideBeaconEndpoint
	TelemetryKeysServerSideEndpoint
)

Local telemetry constants

View Source
const (
	HistoricTelemetryGranularityMinute = iota
	HistoricTelemetryGranularityHour
	HistoricTelemetryGranularityDay
)

Granularity selection constants to be used upon component instantiation

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 ErrSinceParamTooOld = errors.New("summary for requested change number not cached")

ErrSinceParamTooOld 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 ForResource added in v5.0.4

type ForResource struct {
	Latencies    []int64       `json:"latencies"`
	StatusCodes  map[int]int64 `json:"statusCodes"`
	RequestCount int           `json:"requestCount"`
}

ForResource bundles latencies & status code for a specific timeslice

type ForTimeSlice added in v5.0.4

type ForTimeSlice struct {
	TimeSlice int64                  `json:"timeslice"`
	Resources map[string]ForResource `json:"resources"`
}

ForTimeSlice stores all the data for a certain time-slice

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 ProxyRuleBasedSegmentsStorage added in v5.11.0

type ProxyRuleBasedSegmentsStorage interface {
	ChangesSince(since int64) (*dtos.RuleBasedSegmentsDTO, error)
}

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

type ProxyRuleBasedSegmentsStorageImpl added in v5.11.0

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

ProxyRuleBasedSegmentsStorageImpl implements the ProxyRuleBasedSegmentsStorage interface and the RuleBasedSegmentProducer interface

func NewProxyRuleBasedSegmentsStorage added in v5.11.0

func NewProxyRuleBasedSegmentsStorage(db persistent.DBWrapper, logger logging.LoggerInterface, restoreBackup bool) *ProxyRuleBasedSegmentsStorageImpl

NewProxyRuleBasedSegmentsStorage instantiates a new proxy storage that wraps an in-memory snapshot of the last known flag configuration

func (*ProxyRuleBasedSegmentsStorageImpl) All added in v5.11.0

All call is forwarded to the snapshot

func (*ProxyRuleBasedSegmentsStorageImpl) ChangeNumber added in v5.11.0

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

ChangeNumber returns the current change number

func (*ProxyRuleBasedSegmentsStorageImpl) ChangesSince added in v5.11.0

ChangesSince retrieves the rule-based segments changes since the given change number

func (*ProxyRuleBasedSegmentsStorageImpl) Contains added in v5.11.0

func (p *ProxyRuleBasedSegmentsStorageImpl) Contains(rbs []string) bool

Contains checks if the given rule-based segments are present in storage

func (*ProxyRuleBasedSegmentsStorageImpl) FetchMany added in v5.11.0

FetchMany fetches rule-based segments in the storage and returns an array of rule-based segments dtos

func (*ProxyRuleBasedSegmentsStorageImpl) GetRuleBasedSegmentByName added in v5.11.0

func (p *ProxyRuleBasedSegmentsStorageImpl) GetRuleBasedSegmentByName(name string) (*dtos.RuleBasedSegmentDTO, error)

GetRuleBasedSegmentByName retrieves a rule-based segment by name

func (*ProxyRuleBasedSegmentsStorageImpl) LargeSegments added in v5.11.0

LargeSegments call is forwarded to the snapshot

func (*ProxyRuleBasedSegmentsStorageImpl) ReplaceAll added in v5.11.0

ReplaceAll replaces all rule-based segments in storage

func (*ProxyRuleBasedSegmentsStorageImpl) RuleBasedSegmentNames added in v5.11.0

func (p *ProxyRuleBasedSegmentsStorageImpl) RuleBasedSegmentNames() ([]string, error)

RuleBasedSegmentNames retrieves the names of all rule-based segments

func (*ProxyRuleBasedSegmentsStorageImpl) Segments added in v5.11.0

Segments retrieves the names of all segments used in rule-based segments

func (*ProxyRuleBasedSegmentsStorageImpl) SetChangeNumber added in v5.11.0

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

SetChangeNumber sets the change number

func (*ProxyRuleBasedSegmentsStorageImpl) Update added in v5.11.0

func (p *ProxyRuleBasedSegmentsStorageImpl) Update(toAdd []dtos.RuleBasedSegmentDTO, toRemove []dtos.RuleBasedSegmentDTO, changeNumber int64) error

Update

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 feature flags 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) NamesAndCount added in v5.0.4

func (s *ProxySegmentStorageImpl) NamesAndCount() map[string]int

NamesAndCount returns a map of segment names to key count

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, flagSets []string) (*dtos.SplitChangesDTO, error)
}

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, flagSets flagsets.FlagSetFilter, 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, flagSets []string) (*dtos.SplitChangesDTO, error)

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

func (*ProxySplitStorageImpl) Count added in v5.0.4

func (p *ProxySplitStorageImpl) Count() int

Count returns the number of cached feature flags

func (*ProxySplitStorageImpl) FetchMany

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

FetchMany call is forwarded to the snapshot

func (*ProxySplitStorageImpl) GetAllFlagSetNames added in v5.6.0

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

GetAllFlagSetNames implements storage.SplitStorage

func (*ProxySplitStorageImpl) GetNamesByFlagSets added in v5.6.0

func (p *ProxySplitStorageImpl) GetNamesByFlagSets(sets []string) map[string][]string

GetNamesByFlagSets implements storage.SplitStorage

func (*ProxySplitStorageImpl) KillLocally

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

KillLocally marks a feature flag as killed in the current storage

func (*ProxySplitStorageImpl) LargeSegmentNames added in v5.9.0

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

LargeSegmentNames call is forwarded to the snapshot

func (*ProxySplitStorageImpl) Remove

func (p *ProxySplitStorageImpl) Remove(name string)

Remove deletes a split by name

func (*ProxySplitStorageImpl) ReplaceAll added in v5.11.0

func (p *ProxySplitStorageImpl) ReplaceAll(splits []dtos.SplitDTO, changeNumber int64) error

func (*ProxySplitStorageImpl) RuleBasedSegmentNames added in v5.11.0

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

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
	storage.TelemetryPeeker
	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

type TimeSliceData added in v5.0.4

type TimeSliceData []ForTimeSlice

TimeSliceData splits the latest metrics in N entries of fixed x-seconds width timeslices

type TimeslicedProxyEndpointTelemetry added in v5.0.4

type TimeslicedProxyEndpointTelemetry interface {
	ProxyTelemetryFacade
	TimeslicedReport() TimeSliceData
	TotalMetricsReport() map[string]ForResource
}

TimeslicedProxyEndpointTelemetry is a proxy telemetry facade (yet another) that bundles global data and historic data by timeslice (for observability purposes)

type TimeslicedProxyEndpointTelemetryImpl added in v5.0.4

type TimeslicedProxyEndpointTelemetryImpl struct {
	ProxyTelemetryFacade
	// contains filtered or unexported fields
}

TimeslicedProxyEndpointTelemetryImpl is an implementation of `TimeslicedProxyEnxpointTelemetry`

func NewTimeslicedProxyEndpointTelemetry added in v5.0.4

func NewTimeslicedProxyEndpointTelemetry(wrapped ProxyTelemetryFacade, width int64, maxTimeSlices int) *TimeslicedProxyEndpointTelemetryImpl

NewTimeslicedProxyEndpointTelemetry constructs a new timesliced proxy-endpoint telemetry

func (*TimeslicedProxyEndpointTelemetryImpl) IncrEndpointStatus added in v5.0.4

func (t *TimeslicedProxyEndpointTelemetryImpl) IncrEndpointStatus(endpoint int, status int)

IncrEndpointStatus increments the status code count for a specific endpont/status code (global + historic records are updated)

func (*TimeslicedProxyEndpointTelemetryImpl) RecordEndpointLatency added in v5.0.4

func (t *TimeslicedProxyEndpointTelemetryImpl) RecordEndpointLatency(endpoint int, latency time.Duration)

RecordEndpointLatency increments the latency bucket for a specific endpoint (global + historic records are updated)

func (*TimeslicedProxyEndpointTelemetryImpl) TimeslicedReport added in v5.0.4

TimeslicedReport returns a report of the latest metrics split into N time-slices

func (*TimeslicedProxyEndpointTelemetryImpl) TotalMetricsReport added in v5.0.5

func (t *TimeslicedProxyEndpointTelemetryImpl) TotalMetricsReport() map[string]ForResource

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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