Documentation ¶
Index ¶
- Constants
- Variables
- func NewImpressionStorage(client *redis.PrefixedRedisClient, metadata dtos.Metadata, ...) storage.ImpressionStorage
- func NewImpressionsCountStorage(client *redis.PrefixedRedisClient, logger logging.LoggerInterface) storage.ImpressionsCountStorage
- func NewRedisClient(config *conf.RedisConfig, logger logging.LoggerInterface) (*redis.PrefixedRedisClient, error)
- func NewSegmentStorage(redisClient *redis.PrefixedRedisClient, logger logging.LoggerInterface) storage.SegmentStorage
- func NewTelemetryStorage(redisClient *redis.PrefixedRedisClient, logger logging.LoggerInterface, ...) storage.TelemetryRedisProducer
- func NewUniqueKeysMultiSdkConsumer(redisClient *redis.PrefixedRedisClient, logger logging.LoggerInterface) storage.UniqueKeysMultiSdkConsumer
- type EventsStorage
- func (r *EventsStorage) Count() int64
- func (r *EventsStorage) Drop(size int64) error
- func (r *EventsStorage) Empty() bool
- func (r *EventsStorage) PopNRaw(n int64) ([]string, int64, error)
- func (r *EventsStorage) PopNWithMetadata(n int64) ([]dtos.QueueStoredEventDTO, error)
- func (r *EventsStorage) Push(event dtos.EventDTO, _ int) error
- type ImpressionStorage
- func (r *ImpressionStorage) Count() int64
- func (r *ImpressionStorage) Drop(size int64) error
- func (r *ImpressionStorage) Empty() bool
- func (r *ImpressionStorage) LogImpressions(impressions []dtos.Impression) error
- func (r *ImpressionStorage) PopN(n int64) ([]dtos.Impression, error)
- func (r *ImpressionStorage) PopNRaw(n int64) ([]string, int64, error)
- func (r *ImpressionStorage) PopNWithMetadata(n int64) ([]dtos.ImpressionQueueObject, error)
- type ImpressionsCountStorageImp
- type MiscStorage
- type SegmentStorage
- func (r *SegmentStorage) ChangeNumber(segmentName string) (int64, error)
- func (r *SegmentStorage) Keys(segmentName string) *set.ThreadUnsafeSet
- func (r *SegmentStorage) SegmentContainsKey(segmentName string, key string) (bool, error)
- func (r *SegmentStorage) SegmentKeysCount() int64
- func (r *SegmentStorage) SetChangeNumber(segmentName string, changeNumber int64) error
- func (r *SegmentStorage) Size(name string) (int, error)
- func (r *SegmentStorage) Update(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet, ...) error
- func (r *SegmentStorage) UpdateWithSummary(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet, ...) (int, int, error)
- type SegmentUpdateError
- type SplitStorage
- func (r *SplitStorage) All() []dtos.SplitDTO
- func (r *SplitStorage) ChangeNumber() (int64, error)
- func (r *SplitStorage) FetchMany(features []string) map[string]*dtos.SplitDTO
- func (r *SplitStorage) KillLocally(splitName string, defaultTreatment string, changeNumber int64)
- func (r *SplitStorage) SegmentNames() *set.ThreadUnsafeSet
- func (r *SplitStorage) SetChangeNumber(changeNumber int64) error
- func (r *SplitStorage) Split(feature string) *dtos.SplitDTO
- func (r *SplitStorage) SplitNames() []string
- func (r *SplitStorage) TrafficTypeExists(trafficType string) bool
- func (r *SplitStorage) Update(toAdd []dtos.SplitDTO, toRemove []dtos.SplitDTO, changeNumber int64)
- func (r *SplitStorage) UpdateWithErrors(toAdd []dtos.SplitDTO, toRemove []dtos.SplitDTO, changeNumber int64) error
- type TelemetryStorage
- func (t *TelemetryStorage) RecordBURTimeout()
- func (t *TelemetryStorage) RecordConfigData(configData dtos.Config) error
- func (t *TelemetryStorage) RecordException(method string)
- func (t *TelemetryStorage) RecordLatency(method string, latency time.Duration)
- func (t *TelemetryStorage) RecordNonReadyUsage()
- func (t *TelemetryStorage) RecordUniqueKeys(uniques dtos.Uniques) error
- type UniqueKeysMultiSdkConsumer
- type UpdateError
Constants ¶
const ( KeySplit = "SPLITIO.split.{split}" // split object KeySplitTill = "SPLITIO.splits.till" // last split fetch KeySegment = "SPLITIO.segment.{segment}" // segment object KeySegmentTill = "SPLITIO.segment.{segment}.till" // last segment fetch KeyEvents = "SPLITIO.events" // events LIST key KeyImpressionsQueue = "SPLITIO.impressions" // impressions LIST key KeyTrafficType = "SPLITIO.trafficType.{trafficType}" // traffic Type fetch KeyAPIKeyHash = "SPLITIO.hash" // hash key KeyConfig = "SPLITIO.telemetry.config" // config Key KeyLatency = "SPLITIO.telemetry.latencies" // latency Key KeyException = "SPLITIO.telemetry.exceptions" // exception Key KeyUniquekeys = "SPLITIO.uniquekeys" // Unique keys KeyImpressionsCount = "SPLITIO.impressions.count" // impressions count FieldLatency = "{sdkVersion}/{machineName}/{machineIP}/{method}/{bucket}" // latency field template FieldException = "{sdkVersion}/{machineName}/{machineIP}/{method}" // exception field template TTLImpressions = 3600 // impressions default TTL TTLConfig = 3600 // config TTL TTLUniquekeys = 3600 // Uniquekeys TTL // TODO(mredolatti): when doing a breking change, name this `KeyConfig`, and rename `KeyConfig` to `KeyConfigLegacy`, // or even better, remove the old one, so that it only exists in the split-sync KeyInit = "SPLITIO.telemetry.init" InitHashFields = "{sdkVersion}/{machineName}/{machineIP}" )
Split redis keys, fields & TTLs
const ( FieldLatencyIndexSdkVersion = 0 FieldLatencyIndexMachineName = 1 FieldLatencyIndexMachineIP = 2 FieldLatencyIndexMethod = 3 FieldLatencyIndexBucket = 4 )
Latency field section indexes
const ( FieldExceptionIndexSdkVersion = 0 FieldExceptionIndexMachineName = 1 FieldExceptionIndexMachineIP = 2 FieldExceptionIndexMethod = 3 )
Exception field section indexes
const ( TelemetryConfigIndexSdkVersion = 0 TelemetryConfigIndexMachineName = 1 TelemetryConfigIndexMachineIP = 2 )
Latency hash-key indexes
const ErrorHashNotPresent = "hash-not-present"
ErrorHashNotPresent constant
const (
FieldSeparator = "/"
)
FieldSeparator constant
Variables ¶
var ( ErrInvalidConf = errors.New("incompatible configuration of redis, Sentinel and Cluster cannot be enabled at the same time") ErrSentinelNoMaster = errors.New("Missing redis sentinel master name") ErrClusterInvalidHashtag = errors.New("hashtag must be wrapped in '{', '}', and be at least 3 characters long") )
Redis initialization erorrs
var (
ErrChangeNumberUpdateFailed = errors.New("failed to update change number")
)
Public errors
Functions ¶
func NewImpressionStorage ¶
func NewImpressionStorage(client *redis.PrefixedRedisClient, metadata dtos.Metadata, logger logging.LoggerInterface) storage.ImpressionStorage
NewImpressionStorage creates a new RedisSplitStorage and returns a reference to it
func NewImpressionsCountStorage ¶
func NewImpressionsCountStorage(client *redis.PrefixedRedisClient, logger logging.LoggerInterface) storage.ImpressionsCountStorage
func NewRedisClient ¶
func NewRedisClient(config *conf.RedisConfig, logger logging.LoggerInterface) (*redis.PrefixedRedisClient, error)
NewRedisClient returns a new Prefixed Redis Client
func NewSegmentStorage ¶
func NewSegmentStorage(redisClient *redis.PrefixedRedisClient, logger logging.LoggerInterface) storage.SegmentStorage
NewSegmentStorage creates a new RedisSegmentStorage and returns a reference to it TODO(mredolatti): This should return the concrete type, not the implementation
func NewTelemetryStorage ¶
func NewTelemetryStorage(redisClient *redis.PrefixedRedisClient, logger logging.LoggerInterface, metadata dtos.Metadata) storage.TelemetryRedisProducer
NewTelemetryStorage creates a new RedisTelemetryStorage and returns a reference to it
func NewUniqueKeysMultiSdkConsumer ¶
func NewUniqueKeysMultiSdkConsumer( redisClient *redis.PrefixedRedisClient, logger logging.LoggerInterface, ) storage.UniqueKeysMultiSdkConsumer
Types ¶
type EventsStorage ¶
type EventsStorage struct {
// contains filtered or unexported fields
}
EventsStorage redis implementation of EventsStorage interface
func NewEventStorageConsumer ¶
func NewEventStorageConsumer(redisClient *redis.PrefixedRedisClient, metadata dtos.Metadata, logger logging.LoggerInterface) *EventsStorage
NewEventStorageConsumer storage for consumer
func NewEventsStorage ¶
func NewEventsStorage(redisClient *redis.PrefixedRedisClient, metadata dtos.Metadata, logger logging.LoggerInterface) *EventsStorage
NewEventsStorage returns an instance of RedisEventsStorage
func (*EventsStorage) Count ¶
func (r *EventsStorage) Count() int64
Count returns the number of items in the redis list
func (*EventsStorage) Drop ¶
func (r *EventsStorage) Drop(size int64) error
Drop drops events from queue
func (*EventsStorage) Empty ¶
func (r *EventsStorage) Empty() bool
Empty returns true if redis list is zero length
func (*EventsStorage) PopNRaw ¶
func (r *EventsStorage) PopNRaw(n int64) ([]string, int64, error)
PopNRaw pops N elements and returns them as raw strings
func (*EventsStorage) PopNWithMetadata ¶
func (r *EventsStorage) PopNWithMetadata(n int64) ([]dtos.QueueStoredEventDTO, error)
PopNWithMetadata pop N elements from queue
type ImpressionStorage ¶
type ImpressionStorage struct {
// contains filtered or unexported fields
}
ImpressionStorage is a redis-based implementation of split storage
func (*ImpressionStorage) Count ¶
func (r *ImpressionStorage) Count() int64
Count returns the size of the impressions queue
func (*ImpressionStorage) Drop ¶
func (r *ImpressionStorage) Drop(size int64) error
Drop drops impressions from queue
func (*ImpressionStorage) Empty ¶
func (r *ImpressionStorage) Empty() bool
Empty returns true if redis list is zero length
func (*ImpressionStorage) LogImpressions ¶
func (r *ImpressionStorage) LogImpressions(impressions []dtos.Impression) error
LogImpressions stores impressions in redis as Queue
func (*ImpressionStorage) PopN ¶
func (r *ImpressionStorage) PopN(n int64) ([]dtos.Impression, error)
PopN no-op
func (*ImpressionStorage) PopNRaw ¶
func (r *ImpressionStorage) PopNRaw(n int64) ([]string, int64, error)
PopNRaw pops N elements and returns them as raw strings, and how many items are left in the queue
func (*ImpressionStorage) PopNWithMetadata ¶
func (r *ImpressionStorage) PopNWithMetadata(n int64) ([]dtos.ImpressionQueueObject, error)
PopNWithMetadata pop N elements from queue
type ImpressionsCountStorageImp ¶
type ImpressionsCountStorageImp struct {
// contains filtered or unexported fields
}
func (*ImpressionsCountStorageImp) GetImpressionsCount ¶
func (r *ImpressionsCountStorageImp) GetImpressionsCount() (*dtos.ImpressionsCountDTO, error)
func (*ImpressionsCountStorageImp) RecordImpressionsCount ¶
func (r *ImpressionsCountStorageImp) RecordImpressionsCount(impressions dtos.ImpressionsCountDTO) error
type MiscStorage ¶
type MiscStorage struct {
// contains filtered or unexported fields
}
MiscStorage provides methods to handle the synchronizer's initialization procedure
func NewMiscStorage ¶
func NewMiscStorage(client *redis.PrefixedRedisClient, logger logging.LoggerInterface) *MiscStorage
NewMiscStorage creates a new MiscStorageAdapter and returns a reference to it
func (*MiscStorage) ClearAll ¶
func (m *MiscStorage) ClearAll() error
ClearAll cleans previous used data
func (*MiscStorage) GetApikeyHash ¶
func (m *MiscStorage) GetApikeyHash() (string, error)
GetApikeyHash gets hashed apikey from redis
func (*MiscStorage) SetApikeyHash ¶
func (m *MiscStorage) SetApikeyHash(newApikeyHash string) error
SetApikeyHash sets hashed apikey in redis
type SegmentStorage ¶
type SegmentStorage struct {
// contains filtered or unexported fields
}
SegmentStorage is a redis implementation of a storage for segments
func (*SegmentStorage) ChangeNumber ¶
func (r *SegmentStorage) ChangeNumber(segmentName string) (int64, error)
ChangeNumber returns the changeNumber for a particular segment
func (*SegmentStorage) Keys ¶
func (r *SegmentStorage) Keys(segmentName string) *set.ThreadUnsafeSet
Keys returns segments keys for segment if it's present
func (*SegmentStorage) SegmentContainsKey ¶
func (r *SegmentStorage) SegmentContainsKey(segmentName string, key string) (bool, error)
SegmentContainsKey returns true if the segment contains a specific key
func (*SegmentStorage) SegmentKeysCount ¶
func (r *SegmentStorage) SegmentKeysCount() int64
SegmentKeysCount method
func (*SegmentStorage) SetChangeNumber ¶
func (r *SegmentStorage) SetChangeNumber(segmentName string, changeNumber int64) error
SetChangeNumber sets the till value belong to segmentName
func (*SegmentStorage) Size ¶
func (r *SegmentStorage) Size(name string) (int, error)
Size returns the number of keys in a segment
func (*SegmentStorage) Update ¶
func (r *SegmentStorage) Update(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet, till int64) error
Update adds a new segment
func (*SegmentStorage) UpdateWithSummary ¶
func (r *SegmentStorage) UpdateWithSummary(name string, toAdd *set.ThreadUnsafeSet, toRemove *set.ThreadUnsafeSet, till int64) (int, int, error)
UpdateWithSummary returns errors instead of just logging them. This method should replace the current Update which should be deprecated in the next breaking change
type SegmentUpdateError ¶
SegmentUpdateError includes possible failures when adding and removing keys from a segment
func (*SegmentUpdateError) Error ¶
func (s *SegmentUpdateError) Error() string
type SplitStorage ¶
type SplitStorage struct {
// contains filtered or unexported fields
}
SplitStorage is a redis-based implementation of split storage
func NewSplitStorage ¶
func NewSplitStorage(redisClient *redis.PrefixedRedisClient, logger logging.LoggerInterface) *SplitStorage
NewSplitStorage creates a new RedisSplitStorage and returns a reference to it
func (*SplitStorage) All ¶
func (r *SplitStorage) All() []dtos.SplitDTO
All returns a slice of splits dtos.
func (*SplitStorage) ChangeNumber ¶
func (r *SplitStorage) ChangeNumber() (int64, error)
ChangeNumber returns the latest split changeNumber
func (*SplitStorage) FetchMany ¶
func (r *SplitStorage) FetchMany(features []string) map[string]*dtos.SplitDTO
FetchMany retrieves features from redis storage
func (*SplitStorage) KillLocally ¶
func (r *SplitStorage) KillLocally(splitName string, defaultTreatment string, changeNumber int64)
KillLocally mock
func (*SplitStorage) SegmentNames ¶
func (r *SplitStorage) SegmentNames() *set.ThreadUnsafeSet
SegmentNames returns a slice of strings with all the segment names
func (*SplitStorage) SetChangeNumber ¶
func (r *SplitStorage) SetChangeNumber(changeNumber int64) error
SetChangeNumber sets the till value belong to segmentName
func (*SplitStorage) Split ¶
func (r *SplitStorage) Split(feature string) *dtos.SplitDTO
Split fetches a feature in redis and returns a pointer to a split dto
func (*SplitStorage) SplitNames ¶
func (r *SplitStorage) SplitNames() []string
SplitNames returns a slice of strings with all the split names
func (*SplitStorage) TrafficTypeExists ¶
func (r *SplitStorage) TrafficTypeExists(trafficType string) bool
TrafficTypeExists returns true or false depending on existence and counter of trafficType
func (*SplitStorage) UpdateWithErrors ¶
func (r *SplitStorage) UpdateWithErrors(toAdd []dtos.SplitDTO, toRemove []dtos.SplitDTO, changeNumber int64) error
UpdateWithErrors updates the storage and reports errors on a per-feature basis To-be-deprecated: This method should be renamed to `Update` as the current one is removed
type TelemetryStorage ¶
type TelemetryStorage struct {
// contains filtered or unexported fields
}
TelemetryStorage is a redis-based implementation of telemetry storage
func (*TelemetryStorage) RecordBURTimeout ¶
func (t *TelemetryStorage) RecordBURTimeout()
RecordBURTimeout records bur timeodout
func (*TelemetryStorage) RecordConfigData ¶
func (t *TelemetryStorage) RecordConfigData(configData dtos.Config) error
RecordConfigData push config into queue
func (*TelemetryStorage) RecordException ¶
func (t *TelemetryStorage) RecordException(method string)
RecordException stores exceptions for method
func (*TelemetryStorage) RecordLatency ¶
func (t *TelemetryStorage) RecordLatency(method string, latency time.Duration)
RecordLatency stores latency for method
func (*TelemetryStorage) RecordNonReadyUsage ¶
func (t *TelemetryStorage) RecordNonReadyUsage()
RecordNonReadyUsage records non ready usage
func (*TelemetryStorage) RecordUniqueKeys ¶
func (t *TelemetryStorage) RecordUniqueKeys(uniques dtos.Uniques) error
RecordUniqueKeys records unique keys
type UniqueKeysMultiSdkConsumer ¶
type UniqueKeysMultiSdkConsumer struct {
// contains filtered or unexported fields
}
func (*UniqueKeysMultiSdkConsumer) Count ¶
func (u *UniqueKeysMultiSdkConsumer) Count() int64
type UpdateError ¶
UpdateError contains information on what splits failed to be added/removed and why
func (*UpdateError) Error ¶
func (u *UpdateError) Error() string