Documentation
¶
Index ¶
- Variables
- type Cache
- type DoFn
- type HashCache
- type KeyValCache
- func (k *KeyValCache) Delete(ctx context.Context, key string) error
- func (k *KeyValCache) Get(ctx context.Context, key string, value interface{}) error
- func (k *KeyValCache) HealthCheck(ctx context.Context) error
- func (k *KeyValCache) Keys(ctx context.Context, key string) ([]string, error)
- func (k *KeyValCache) Scan(ctx context.Context, key string) (map[string]string, error)
- func (k *KeyValCache) Set(ctx context.Context, key string, value interface{}) error
- type MemCache
- func (m MemCache) Delete(_ context.Context, key string) error
- func (m MemCache) Get(_ context.Context, key string, v interface{}) error
- func (m MemCache) HealthCheck(_ context.Context) error
- func (m MemCache) Keys(_ context.Context, key string) ([]string, error)
- func (m MemCache) Scan(_ context.Context, _ string) (map[string]string, error)
- func (m MemCache) Set(_ context.Context, key string, value interface{}) error
- type MemoizeMetrics
- type MetricsCache
- func (c MetricsCache) Delete(ctx context.Context, key string) (err error)
- func (c MetricsCache) Get(ctx context.Context, key string, v interface{}) (err error)
- func (c MetricsCache) HealthCheck(ctx context.Context) error
- func (c MetricsCache) Keys(ctx context.Context, key string) ([]string, error)
- func (c MetricsCache) Scan(ctx context.Context, key string) (m map[string]string, err error)
- func (c MetricsCache) Set(ctx context.Context, key string, value interface{}) (err error)
- type Options
- type Refresher
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnexpectedMessageDomain is the error returned when an SSE message has a message domain we aren't expecting ErrUnexpectedMessageDomain = errors.New("unexpected message domain") // ErrUnexpectedEventType is the error returned when an SSE message has an event type we aren't expecting ErrUnexpectedEventType = errors.New("unexpected event type") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Set sets a value in the cache for a given key and field
Set(ctx context.Context, key string, value interface{}) error
// Get gets the value of a field for a given key
Get(ctx context.Context, key string, value interface{}) error
// Delete removes a key from the cache
Delete(ctx context.Context, key string) error
// Keys returns a list of keys that match the pattern
Keys(ctx context.Context, key string) ([]string, error)
// HealthCheck checks cache health
HealthCheck(ctx context.Context) error
// Scan all the keys for given key
Scan(ctx context.Context, key string) (map[string]string, error)
}
Cache is the interface for a key value cache
func NewMemoizeCache ¶
func NewMemoizeCache(rc redis.UniversalClient, defaultExpiration, cleanupInterval time.Duration, metrics memoizeMetrics) Cache
NewMemoizeCache creates a memoize cache
type HashCache ¶
type HashCache struct {
Cache
// contains filtered or unexported fields
}
The HashCache wraps a Cache implementation (via the MemoizeCache) and adds an in-memory caching layer for serialised data. It contains its own implementations for certain methods of the Cache interface that are specifically used for caching large objects that the Proxy stores.
func NewHashCache ¶
NewHashCache ...
type KeyValCache ¶
type KeyValCache struct {
// contains filtered or unexported fields
}
KeyValCache is a simple abstraction over Redis that provides basic operations for storing, retrieving, and deleting key-value pairs
func NewKeyValCache ¶
func NewKeyValCache(rc redis.UniversalClient, opts ...Options) *KeyValCache
NewKeyValCache instantiates and returns a KeyValCache
func (*KeyValCache) Delete ¶
func (k *KeyValCache) Delete(ctx context.Context, key string) error
Delete can be used to forcefully remove a key from the cache before it's TTL has expired
func (*KeyValCache) Get ¶
func (k *KeyValCache) Get(ctx context.Context, key string, value interface{}) error
Get gets a value from the cache specified by the key
func (*KeyValCache) HealthCheck ¶
func (k *KeyValCache) HealthCheck(ctx context.Context) error
HealthCheck pings the underlying redis cache
type MemCache ¶
MemCache is an in memory cache that stores a map of keys to a map of fields and their values
func (MemCache) HealthCheck ¶
HealthCheck checks cache health we don't have any connection to check here so just return no errors
type MemoizeMetrics ¶
type MemoizeMetrics struct {
// contains filtered or unexported fields
}
MemoizeMetrics implements the memoizeMetrics interface
func NewMemoizeMetrics ¶
func NewMemoizeMetrics(label string, reg *prometheus.Registry) MemoizeMetrics
NewMemoizeMetrics creates a MemoizeMetrics struct that records prometheus metrics that tracks activity in the memoize cache
type MetricsCache ¶
type MetricsCache struct {
// contains filtered or unexported fields
}
MetricsCache is a decorator for a Cache that uses prometheus to track read/write activity in the cache
func NewMetricsCache ¶
func NewMetricsCache(label string, reg prometheus.Registerer, next Cache) MetricsCache
NewMetricsCache creates a MetricsCache
func (MetricsCache) Delete ¶
func (c MetricsCache) Delete(ctx context.Context, key string) (err error)
Delete makes MetricsCache implement the Cache interface. It calls the decorated cache's delete method and uses a prometheus counter and histogram to track the number of calls and how long each call takes
func (MetricsCache) Get ¶
func (c MetricsCache) Get(ctx context.Context, key string, v interface{}) (err error)
Get makes MetricsCache implement the Cache interface. It calls the decorated cache's Get method and uses a prometheus counter and histogram to track the number of calls and how long a Get operation takes.
func (MetricsCache) HealthCheck ¶
func (c MetricsCache) HealthCheck(ctx context.Context) error
HealthCheck calls the decorated cache's HealthCheck method
func (MetricsCache) Keys ¶
Keys makes MetricsCache implement the Cache interface. It calls the decorated cache's Keys method and returns the results. It doesn't record any prometheus metrics.
func (MetricsCache) Set ¶
func (c MetricsCache) Set(ctx context.Context, key string, value interface{}) (err error)
Set makes MetricsCache implement the Cache interface. It calls the decorated cache's Set method and uses a prometheus counter and histogram to track the number of calls and how long a Set operation takes.
type Options ¶
type Options func(k *KeyValCache)
Options defines optional parameters for configuring a KeyValCache
func WithLocalCache ¶
func WithLocalCache(lc cache.LocalCache) Options
WithLocalCache lets you configure the LocalCache e.g. NewKeyValCache("localhost:6379", WithLocalCache(cache.NewTinyLFU(5000, 1 * time.Hour))
func WithMarshalFunc ¶
func WithMarshalFunc(marshalFunc cache.MarshalFunc) Options
WithMarshalFunc lets you set how data is marshaled into the cache
func WithUnmarshalFunc ¶
func WithUnmarshalFunc(unmarshalFunc cache.UnmarshalFunc) Options
WithUnmarshalFunc lets you set how data is unmarshaled from the cache
type Refresher ¶
type Refresher struct {
// contains filtered or unexported fields
}
Refresher is a type for handling SSE events from Harness Saas and making sure that data in the underlying repositories is updated when change events are received.
func NewRefresher ¶
func NewRefresher(l log.Logger, config config, client domain.ClientService, inventory domain.InventoryRepo, authRepo domain.AuthRepo, flagRepo domain.FlagRepo, segmentRepo domain.SegmentRepo) Refresher
NewRefresher creates a Refresher
func (Refresher) HandleMessage ¶
HandleMessage makes Refresher implement the MessageHandler interface