util

package
v0.0.0-...-d51a932 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backoff

func Backoff(rfn func() error) error

func ClearMap

func ClearMap(m map[string]struct{})

func Container

func Container(m map[string]string, k string) bool

func GetBuf

func GetBuf() *bytes.Buffer

func Ipv4Family

func Ipv4Family() *int64

func IterMap

func IterMap(s *hashmap.Map, fn func(k, v interface{}) error)

func PutBuf

func PutBuf(b *bytes.Buffer)

func Rand

func Rand(n int) string

func SetAddList

func SetAddList(s *hashset.Set, l []string)

func TimeBackoff

func TimeBackoff(rfn func() error) error

Types

type CallbackFn

type CallbackFn func(any)

type Event

type Event int
const (
	UpdateE Event = iota
	DeleteE
	CreateE
)

type Parameters

type Parameters struct {
	// MinInterval is the minimum required interval between invocations of
	// TriggerFunc
	MinInterval time.Duration

	// TriggerFunc is the function to be called when Trigger() is called
	// while respecting MinInterval and serialization
	TriggerFunc func()

	// ShutdownFunc is called when the trigger is shut down
	ShutdownFunc func()

	// Name is the unique name of the trigger. It must be provided in a
	// format compatible to be used as prometheus name string.
	Name string
}

Parameters are the user specified parameters

type PrioList

type PrioList struct {
	*binaryheap.Heap
	// contains filtered or unexported fields
}

func NewPrioIntList

func NewPrioIntList() *PrioList

func NewPrioStringList

func NewPrioStringList() *PrioList

func (*PrioList) Pop

func (pl *PrioList) Pop() (any, bool)

func (*PrioList) Push

func (pl *PrioList) Push(s any)

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

Trigger represents an active trigger logic. Use NewTrigger() to create a trigger

func NewTrigger

func NewTrigger(p Parameters) (*Trigger, error)

NewTrigger returns a new trigger based on the provided parameters

func (*Trigger) Shutdown

func (t *Trigger) Shutdown()

Shutdown stops the trigger mechanism

func (*Trigger) Trigger

func (t *Trigger) Trigger()

Trigger triggers the call to TriggerFunc as specified in the parameters provided to NewTrigger(). It respects MinInterval and ensures that calls to TriggerFunc are serialized. This function is non-blocking and will return immediately before TriggerFunc is potentially triggered and has completed.

Jump to

Keyboard shortcuts

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