Documentation ¶
Index ¶
- func Batcher(closeCh <-chan struct{}, maxBatchLength int, batchTimeout time.Duration, ...)
- func CloseExitChannel()
- func ExitChannel() <-chan struct{}
- func GenerateConnectionFlowEntries(nConnections int) []config.GenericMap
- func InitExitChannel()
- func SetupElegantExit()
- func SetupSASLMechanism(cfg *api.SASLConfig) (sasl.Mechanism, error)
- type CacheCallback
- type Key
- type MultiOrderedMap
- func (mom MultiOrderedMap) AddRecord(key Key, record Record) error
- func (mom MultiOrderedMap) GetRecord(key Key) (Record, bool)
- func (mom MultiOrderedMap) IterateFrontToBack(orderID OrderID, f processRecordFunc)
- func (mom MultiOrderedMap) Len() int
- func (mom MultiOrderedMap) MoveToBack(key Key, orderID OrderID) error
- func (mom MultiOrderedMap) MoveToFront(key Key, orderID OrderID) error
- func (mom MultiOrderedMap) RemoveRecord(key Key)
- type OrderID
- type Record
- type TimedCache
- func (tc *TimedCache) CleanupExpiredEntries(expiry time.Duration, callback CacheCallback)
- func (tc *TimedCache) GetCacheEntry(key string) (interface{}, bool)
- func (tc *TimedCache) GetCacheLen() int
- func (tc *TimedCache) Iterate(f func(key string, value interface{}))
- func (tc *TimedCache) UpdateCacheEntry(key string, entry interface{}) (*cacheEntry, bool)
- type TimedCacheMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Batcher ¶ added in v0.1.4
func Batcher( closeCh <-chan struct{}, maxBatchLength int, batchTimeout time.Duration, inCh <-chan config.GenericMap, action func([]config.GenericMap), )
func CloseExitChannel ¶ added in v0.1.6
func CloseExitChannel()
func ExitChannel ¶
func ExitChannel() <-chan struct{}
func GenerateConnectionFlowEntries ¶ added in v0.1.9
func GenerateConnectionFlowEntries(nConnections int) []config.GenericMap
GenerateConnectionFlowEntries generates data with one entry for each of nConnections Create the entries in a predictable manner so that the first K entries in each call to the function reproduce the same connection. avoid using addresses 0 and 255 since these sometimes have special meanings.
func InitExitChannel ¶ added in v0.1.6
func InitExitChannel()
InitExitChannel and CloseExitChannel are needed for some tests
func SetupElegantExit ¶
func SetupElegantExit()
func SetupSASLMechanism ¶ added in v0.1.9
func SetupSASLMechanism(cfg *api.SASLConfig) (sasl.Mechanism, error)
Types ¶
type CacheCallback ¶
type CacheCallback func(entry interface{})
type MultiOrderedMap ¶ added in v0.1.4
type MultiOrderedMap struct {
// contains filtered or unexported fields
}
func NewMultiOrderedMap ¶ added in v0.1.4
func NewMultiOrderedMap(orderIDs ...OrderID) *MultiOrderedMap
NewMultiOrderedMap returns an initialized MultiOrderedMap.
func (MultiOrderedMap) AddRecord ¶ added in v0.1.4
func (mom MultiOrderedMap) AddRecord(key Key, record Record) error
AddRecord adds a record to the multi-ordered map.
func (MultiOrderedMap) GetRecord ¶ added in v0.1.4
func (mom MultiOrderedMap) GetRecord(key Key) (Record, bool)
GetRecord returns the record of key `key` and true if the key exists. Otherwise, nil and false is returned.
func (MultiOrderedMap) IterateFrontToBack ¶ added in v0.1.4
func (mom MultiOrderedMap) IterateFrontToBack(orderID OrderID, f processRecordFunc)
IterateFrontToBack iterates over the records by orderID. It applies function f() on each record. f() returns two booleans `delete` and `stop` that control whether to remove the record from the multi-ordered map and whether to stop the iteration respectively.
func (MultiOrderedMap) Len ¶ added in v0.1.4
func (mom MultiOrderedMap) Len() int
Len returns the number of records of the multi-ordered map mom.
func (MultiOrderedMap) MoveToBack ¶ added in v0.1.4
func (mom MultiOrderedMap) MoveToBack(key Key, orderID OrderID) error
MoveToBack moves the record of key `key` to the back of orderID. If the key or the orderID doesn't exist, an error is returned.
func (MultiOrderedMap) MoveToFront ¶ added in v0.1.9
func (mom MultiOrderedMap) MoveToFront(key Key, orderID OrderID) error
MoveToFront moves the record of key `key` to the front of orderID. If the key or the orderID doesn't exist, an error is returned.
func (MultiOrderedMap) RemoveRecord ¶ added in v0.1.4
func (mom MultiOrderedMap) RemoveRecord(key Key)
RemoveRecord removes the record of key `key`. If the key doesn't exist, RemoveRecord is a no-op.
type TimedCache ¶
type TimedCache struct {
// contains filtered or unexported fields
}
If maxEntries is non-zero, this limits the number of entries in the cache to the number specified. If maxEntries is zero, the cache has no size limit.
func NewQuietExpiringTimedCache ¶ added in v0.1.7
func NewQuietExpiringTimedCache(expiry time.Duration) *TimedCache
func NewTimedCache ¶
func NewTimedCache(maxEntries int, cacheLenMetric prometheus.Gauge) *TimedCache
func (*TimedCache) CleanupExpiredEntries ¶
func (tc *TimedCache) CleanupExpiredEntries(expiry time.Duration, callback CacheCallback)
CleanupExpiredEntries removes items from cache that were last touched more than expiryTime seconds ago
func (*TimedCache) GetCacheEntry ¶
func (tc *TimedCache) GetCacheEntry(key string) (interface{}, bool)
func (*TimedCache) GetCacheLen ¶
func (tc *TimedCache) GetCacheLen() int
func (*TimedCache) Iterate ¶
func (tc *TimedCache) Iterate(f func(key string, value interface{}))
We expect that the function calling Iterate might make updates to the entries by calling UpdateCacheEntry() We therefore cannot take the lock at this point since it will conflict with the call in UpdateCacheEntry() TODO: If the callback needs to update the cache, then we need a method to perform it without taking the lock again.
func (*TimedCache) UpdateCacheEntry ¶
func (tc *TimedCache) UpdateCacheEntry(key string, entry interface{}) (*cacheEntry, bool)
If cache entry exists, update it and return it; if it does not exist, create it if there is room. If we exceed the size of the cache, then do not allocate new entry
type TimedCacheMap ¶
type TimedCacheMap map[string]*cacheEntry