utils

package
v0.1.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToFloat64

func ConvertToFloat64(unk interface{}) (float64, error)

ConvertToFloat64 converts an unknown type to float Based on https://stackoverflow.com/a/20767884/2749989

func ExitChannel

func ExitChannel() <-chan struct{}

func ParamString

func ParamString(params config.StageParam, stage string, stageType string) string

ParamString returns its corresponding (json) string from config.parameters for specified params structure

func SetupElegantExit

func SetupElegantExit()

Types

type CacheCallback

type CacheCallback interface {
	Cleanup(entry interface{})
}

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

Jump to

Keyboard shortcuts

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