cache

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogCache

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

LogCache is a in memory cache for Loggregator envelopes.

func New

func New(opts ...LogCacheOption) *LogCache

NewLogCache creates a new LogCache.

func (*LogCache) Addr

func (c *LogCache) Addr() string

Addr returns the address that the LogCache is listening on. This is only valid after Start has been invoked.

func (*LogCache) Close

func (c *LogCache) Close() error

Close will shutdown the gRPC server

func (*LogCache) Start

func (c *LogCache) Start()

Start starts the LogCache. It has an internal go-routine that it creates and therefore does not block.

type LogCacheOption

type LogCacheOption func(*LogCache)

LogCacheOption configures a LogCache.

func WithAddr

func WithAddr(addr string) LogCacheOption

WithAddr configures the address to listen for gRPC requests. It defaults to :8080.

func WithClustered

func WithClustered(nodeIndex int, nodeAddrs []string, opts ...grpc.DialOption) LogCacheOption

WithClustered enables the LogCache to route data to peer nodes. It hashes each envelope by SourceId and routes data that does not belong on the node to the correct node. NodeAddrs is a slice of node addresses where the slice index corresponds to the NodeIndex. The current node's address is included. The default is standalone mode where the LogCache will store all the data and forward none of it.

func WithExternalAddr

func WithExternalAddr(addr string) LogCacheOption

WithExternalAddr returns a LogCacheOption that sets address the scheduler will refer to the given node as. This is required when the set address won't match what the scheduler will refer to the node as (e.g. :0). Defaults to the resulting address from the listener.

func WithLogger

func WithLogger(l *log.Logger) LogCacheOption

WithLogger returns a LogCacheOption that configures the logger used for the LogCache. Defaults to silent logger.

func WithMaxPerSource

func WithMaxPerSource(size int) LogCacheOption

WithMaxPerSource returns a LogCacheOption that configures the store's memory size as number of envelopes for a specific sourceID. Defaults to 100000 envelopes.

func WithMemoryLimit

func WithMemoryLimit(memoryPercent float64) LogCacheOption

WithMemoryLimit sets the percentage of total system memory to use for the cache. If exceeded, the cache will prune. Default is 50%.

func WithMetrics

func WithMetrics(m metrics.Initializer) LogCacheOption

WithMetrics returns a LogCacheOption that configures the metrics for the LogCache. It will add metrics to the given map.

func WithQueryTimeout

func WithQueryTimeout(queryTimeout time.Duration) LogCacheOption

WithQueryTimeout sets the maximum allowed runtime of a single PromQL query. The default is 10s. If you increase this limit, make sure to keep in mind that memory usage will increase with longer durations.

func WithServerOpts

func WithServerOpts(opts ...grpc.ServerOption) LogCacheOption

WithServerOpts configures the gRPC server options. It defaults to an empty list.

type MemoryAnalyzer

type MemoryAnalyzer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MemoryAnalyzer reports the available and total memory.

func NewMemoryAnalyzer

func NewMemoryAnalyzer(metrics metrics.Initializer) *MemoryAnalyzer

NewMemoryAnalyzer creates and returns a new MemoryAnalyzer.

func (*MemoryAnalyzer) Memory

func (a *MemoryAnalyzer) Memory() (heapInUse, available, total uint64)

Memory returns the heap memory and total system memory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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