Documentation
¶
Overview ¶
Foliage primary statefun system package. Provides shared system functions for statefun packages
Index ¶
- Variables
- func Base64ToStr(base64Encoded string) string
- func BoolToBytes(b bool) []byte
- func BytesToBool(data []byte) bool
- func BytesToFloat64(b []byte) float64
- func BytesToInt64(v []byte) int64
- func CreateDimSizeChannel[T interface{}](maxBufferElements int, onBufferOverflow func()) (in chan T, out chan T)
- func Float64ToBytes(f float64) []byte
- func GetCurrentTimeNs() int64
- func GetEnv[T interface{}](key string, defaultVal T) (value T, err error)
- func GetEnvMustProceed[T interface{}](key string, defaultVal T) T
- func GetHashStr(str string) string
- func GetUniqueStrID() string
- func Int64ToBytes(v int64) []byte
- func IntToStr(i int64) string
- func MapsIntersection[T interface{}](m1 map[string]T, m2 map[string]T, valuesFromMap1 bool) map[string]T
- func MapsUnion[T interface{}](m1 map[string]T, m2 map[string]T) map[string]T
- func MsgOnErrorReturn(retVars ...interface{})
- func SortJSONs(jsonArray []*easyjson.JSON, fields []string) []*easyjson.JSON
- func SortUUIDs(uuids []string, ascending bool) []string
- func StartHeapWatcher(intervalMins float32)
- func Str2Bool(boolStr string) bool
- func Str2Int(s string) int64
- func StrToBase64(xmlText string) string
- func StringToFloat(s string) float64
- func UniqueStrings(input []string) []string
- type FinalFunc
- type FinalFunctions
- type KeyMutex
- type Prometrics
- func (pm *Prometrics) EnsureGaugeVec(id string, metric *prometheus.GaugeVec) (*prometheus.GaugeVec, error)
- func (pm *Prometrics) EnsureGaugeVecSimple(id string, help string, labelNames []string) (*prometheus.GaugeVec, error)
- func (pm *Prometrics) EnsureHistogramVec(id string, metric *prometheus.HistogramVec) (*prometheus.HistogramVec, error)
- func (pm *Prometrics) EnsureHistogramVecSimple(id string, help string, buckets []float64, labelNames []string) (*prometheus.HistogramVec, error)
- func (pm *Prometrics) Exists(id string) bool
- func (pm *Prometrics) GetRoutinesCounter() *RoutinesCounter
- func (pm *Prometrics) Shutdown()
- type RoutinesCounter
- type RoutinesCounterValue
- type ShardedMap
- func (sm *ShardedMap) Clear()
- func (sm *ShardedMap) Delete(key string)
- func (sm *ShardedMap) Get(key string) (interface{}, bool)
- func (sm *ShardedMap) Has(key string) bool
- func (sm *ShardedMap) Keys() []string
- func (sm *ShardedMap) Len() int
- func (sm *ShardedMap) LoadOrStore(key string, val interface{}) (actual interface{}, loaded bool)
- func (sm *ShardedMap) Range(f func(key string, value interface{}) bool)
- func (sm *ShardedMap) Set(key string, value interface{})
- func (sm *ShardedMap) ShardCount() int
- func (sm *ShardedMap) Snapshot() map[string]interface{}
- type TokenBucket
Constants ¶
This section is empty.
Variables ¶
var ( PrometricDifferentTypeExistsForIdError = errors.New("metrics with a different type exists for an id") PrometricInstanceIsNil = errors.New("prometrics instance the method is being call against to is nil") )
Functions ¶
func Base64ToStr ¶ added in v0.1.6
func BoolToBytes ¶ added in v0.1.6
func BytesToBool ¶ added in v0.1.6
func BytesToFloat64 ¶ added in v0.1.6
func BytesToInt64 ¶
func CreateDimSizeChannel ¶
func CreateDimSizeChannel[T interface{}](maxBufferElements int, onBufferOverflow func()) (in chan T, out chan T)
func Float64ToBytes ¶ added in v0.1.6
func GetCurrentTimeNs ¶
func GetCurrentTimeNs() int64
func GetEnvMustProceed ¶
func GetEnvMustProceed[T interface{}](key string, defaultVal T) T
func GetHashStr ¶
func GetUniqueStrID ¶
func GetUniqueStrID() string
func Int64ToBytes ¶
func MapsIntersection ¶ added in v0.1.3
func MsgOnErrorReturn ¶
func MsgOnErrorReturn(retVars ...interface{})
func StartHeapWatcher ¶ added in v0.1.7
func StartHeapWatcher(intervalMins float32)
func StrToBase64 ¶ added in v0.1.6
func StringToFloat ¶ added in v0.1.6
func UniqueStrings ¶ added in v0.1.6
Types ¶
type FinalFunctions ¶ added in v0.1.6
type FinalFunctions struct {
// contains filtered or unexported fields
}
func NewFinalFunctions ¶ added in v0.1.6
func NewFinalFunctions() *FinalFunctions
func (*FinalFunctions) Add ¶ added in v0.1.6
func (ff *FinalFunctions) Add(f FinalFunc)
func (*FinalFunctions) Exec ¶ added in v0.1.6
func (ff *FinalFunctions) Exec()
type KeyMutex ¶ added in v0.1.3
type KeyMutex struct {
// contains filtered or unexported fields
}
KeyMutex provides per-key read-write mutexes with automatic cleanup. Multiple readers can access a key concurrently if no writer holds the lock.
func NewKeyMutex ¶ added in v0.1.3
func NewKeyMutex() *KeyMutex
NewKeyMutex constructs a new KeyMutex.
func (*KeyMutex) Lock ¶ added in v0.1.3
func (k *KeyMutex) Lock(key interface{})
Lock acquires exclusive (write) lock for the specified key.
func (*KeyMutex) RLock ¶ added in v0.1.6
func (k *KeyMutex) RLock(key interface{})
RLock acquires a shared (read) lock for the specified key.
type Prometrics ¶ added in v0.1.3
type Prometrics struct {
// contains filtered or unexported fields
}
var (
GlobalPrometrics *Prometrics
)
func NewPrometrics ¶ added in v0.1.3
func NewPrometrics(pattern string, addr string) *Prometrics
func (*Prometrics) EnsureGaugeVec ¶ added in v0.1.3
func (pm *Prometrics) EnsureGaugeVec(id string, metric *prometheus.GaugeVec) (*prometheus.GaugeVec, error)
func (*Prometrics) EnsureGaugeVecSimple ¶ added in v0.1.3
func (pm *Prometrics) EnsureGaugeVecSimple(id string, help string, labelNames []string) (*prometheus.GaugeVec, error)
func (*Prometrics) EnsureHistogramVec ¶ added in v0.1.3
func (pm *Prometrics) EnsureHistogramVec(id string, metric *prometheus.HistogramVec) (*prometheus.HistogramVec, error)
func (*Prometrics) EnsureHistogramVecSimple ¶ added in v0.1.3
func (pm *Prometrics) EnsureHistogramVecSimple(id string, help string, buckets []float64, labelNames []string) (*prometheus.HistogramVec, error)
func (*Prometrics) Exists ¶ added in v0.1.3
func (pm *Prometrics) Exists(id string) bool
func (*Prometrics) GetRoutinesCounter ¶ added in v0.1.3
func (pm *Prometrics) GetRoutinesCounter() *RoutinesCounter
func (*Prometrics) Shutdown ¶ added in v0.1.6
func (pm *Prometrics) Shutdown()
type RoutinesCounter ¶ added in v0.1.3
type RoutinesCounter struct {
// contains filtered or unexported fields
}
func (*RoutinesCounter) Read ¶ added in v0.1.3
func (rc *RoutinesCounter) Read(f func(key string, value int64) bool)
func (*RoutinesCounter) Started ¶ added in v0.1.3
func (rc *RoutinesCounter) Started(routineTypeName string)
func (*RoutinesCounter) Stopped ¶ added in v0.1.3
func (rc *RoutinesCounter) Stopped(routineTypeName string)
type RoutinesCounterValue ¶ added in v0.1.3
type RoutinesCounterValue struct {
// contains filtered or unexported fields
}
type ShardedMap ¶
type ShardedMap struct {
// contains filtered or unexported fields
}
ShardedMap is a hash-sharded, concurrency-safe map. Shard selection is based on FNV-1a 64-bit hash of the key.
func SharedMapMustNewHashed ¶
func SharedMapMustNewHashed(shardCount int) *ShardedMap
MustNewHashed creates a sharded map or panics if shardCount is invalid.
func SharedMapNewHashed ¶
func SharedMapNewHashed(shardCount int) (*ShardedMap, error)
NewHashed creates a sharded map with the given number of shards. shardCount must be > 0. If shardCount is a power of two, shard selection is a fast bitmask.
func (*ShardedMap) Delete ¶
func (sm *ShardedMap) Delete(key string)
func (*ShardedMap) Get ¶
func (sm *ShardedMap) Get(key string) (interface{}, bool)
func (*ShardedMap) Has ¶
func (sm *ShardedMap) Has(key string) bool
func (*ShardedMap) Keys ¶
func (sm *ShardedMap) Keys() []string
Keys returns a snapshot of all keys (order unspecified).
func (*ShardedMap) Len ¶
func (sm *ShardedMap) Len() int
Len returns the total number of key/value pairs across all shards. It walks shards sequentially under shared locks.
func (*ShardedMap) LoadOrStore ¶
func (sm *ShardedMap) LoadOrStore(key string, val interface{}) (actual interface{}, loaded bool)
LoadOrStore stores the value only if the key doesn't exist. It returns the actual value and whether the key was already present.
func (*ShardedMap) Range ¶
func (sm *ShardedMap) Range(f func(key string, value interface{}) bool)
Range walks over all (key,value) pairs. It snapshots each shard under RLock, releases the lock, and only then calls f on the copied pairs to avoid lock inversion/starvation.
func (*ShardedMap) Set ¶
func (sm *ShardedMap) Set(key string, value interface{})
func (*ShardedMap) ShardCount ¶
func (sm *ShardedMap) ShardCount() int
ShardCount returns the number of shards.
func (*ShardedMap) Snapshot ¶
func (sm *ShardedMap) Snapshot() map[string]interface{}
Snapshot returns a shallow copy into a standalone map.
type TokenBucket ¶ added in v0.1.6
type TokenBucket struct {
Capacity int
// contains filtered or unexported fields
}
func NewTokenBucket ¶ added in v0.1.6
func NewTokenBucket(cap int) *TokenBucket
func (*TokenBucket) GetLoadPercentage ¶ added in v0.1.6
func (tb *TokenBucket) GetLoadPercentage() float64
func (*TokenBucket) Release ¶ added in v0.1.6
func (tb *TokenBucket) Release()
func (*TokenBucket) TryAcquire ¶ added in v0.1.6
func (tb *TokenBucket) TryAcquire() bool