Documentation
¶
Index ¶
- func Batcher(closeCh <-chan struct{}, maxBatchLength int, batchTimeout time.Duration, ...)
- func CloseExitChannel()
- func ConvertToBool(unk interface{}) (bool, error)
- func ConvertToFloat64(unk interface{}) (float64, error)
- func ConvertToInt(unk interface{}) (int, error)
- func ConvertToInt64(unk interface{}) (int64, error)
- func ConvertToUint32(unk interface{}) (uint32, error)
- func ConvertToUint64(unk interface{}) (uint64, error)
- func ExitChannel() <-chan struct{}
- func InitExitChannel()
- func SetupElegantExit()
- 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) 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 ConvertToBool ¶ added in v0.1.8
func ConvertToFloat64 ¶
ConvertToFloat64 converts an unknown type to float Based on https://stackoverflow.com/a/20767884/2749989
func ConvertToInt ¶ added in v0.1.8
func ConvertToInt64 ¶ added in v0.1.8
func ConvertToUint32 ¶ added in v0.1.8
func ConvertToUint64 ¶ added in v0.1.8
func ExitChannel ¶
func ExitChannel() <-chan struct{}
func InitExitChannel ¶ added in v0.1.6
func InitExitChannel()
InitExitChannel and CloseExitChannel are needed for some tests
func SetupElegantExit ¶
func SetupElegantExit()
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) 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) *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