Documentation
¶
Index ¶
- func Batcher(closeCh <-chan struct{}, maxBatchLength int, batchTimeout time.Duration, ...)
- func CloseExitChannel()
- func ConvertToFloat64(unk interface{}) (float64, 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(expiryTime int64, 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
- 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 ConvertToFloat64 ¶
ConvertToFloat64 converts an unknown type to float Based on https://stackoverflow.com/a/20767884/2749989
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 interface {
Cleanup(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
}
func NewTimedCache ¶
func NewTimedCache() *TimedCache
func (*TimedCache) CleanupExpiredEntries ¶
func (tc *TimedCache) CleanupExpiredEntries(expiryTime int64, 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
type TimedCacheMap ¶
type TimedCacheMap map[string]*cacheEntry