utils

package
v0.0.90 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 36 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Direct = direct{}

Direct is a direct proxy: one that makes network connections directly.

Functions

func ClientIdentifierFromContext added in v0.0.17

func ClientIdentifierFromContext(ctx context.Context) domain.ClientIdentifier

func CompareJson

func CompareJson(a, b []byte) bool

func ContextFromGeneric

func ContextFromGeneric(parent context.Context, generic domain.Generic) context.Context

func ContextFromIdentifiers added in v0.0.5

func ContextFromIdentifiers(parent context.Context, id domain.ClientIdentifier) context.Context

func DeptMsgIdFromContext added in v0.0.59

func DeptMsgIdFromContext(ctx context.Context) (int, string)

func FileContent added in v0.0.65

func FileContent(path string) []byte

func FileToUnstructured added in v0.0.65

func FileToUnstructured(path string) *unstructured.Unstructured

func GetDialer added in v0.0.32

func GetDialer() func(context.Context, string, string) (net.Conn, error)

GetDialer returns a net.DialContext function that uses a proxy if necessary. HTTP_PROXY and HTTPS_PROXY are used to determine the proxy to use. NO_PROXY is currently ignored.

func GreaterOrEqualVersion added in v0.0.63

func GreaterOrEqualVersion(a string, b string) bool

GreaterOrEqualVersion returns true if a version is greater or equal to b

func IsBatchMessageSupported added in v0.0.63

func IsBatchMessageSupported(version string) bool

func NewBackOff added in v0.0.32

func NewBackOff() backoff.BackOff

func NewMsgId added in v0.0.59

func NewMsgId() string

func PulsarMessageIDtoString

func PulsarMessageIDtoString(msgID pulsar.MessageID) string

PulsarMessageIDtoString is taken from github.com/kubescape/event-ingester-service/utils/common.go:func PulsarMessageIDtoString

func ServePprof added in v0.0.36

func ServePprof()

func StartLivenessProbe added in v0.0.17

func StartLivenessProbe()

func StringValueBigger added in v0.0.17

func StringValueBigger(s1, s2 string) bool

Types

type CooldownQueue added in v0.0.8

type CooldownQueue struct {

	// public channel for reading events
	ResultChan <-chan watch.Event
	// contains filtered or unexported fields
}

CooldownQueue is a queue that lets clients put events into it with a cooldown

When a client puts an event into a queue, it waits for a cooldown period before the event is forwarded to the consumer. If and event for the same key is put into the queue again before the cooldown period is over, the event is overridden and the cooldown period is reset.

func NewCooldownQueue added in v0.0.8

func NewCooldownQueue() *CooldownQueue

NewCooldownQueue returns a new Cooldown Queue

func (*CooldownQueue) Closed added in v0.0.25

func (q *CooldownQueue) Closed() bool

func (*CooldownQueue) Enqueue added in v0.0.8

func (q *CooldownQueue) Enqueue(e watch.Event)

Enqueue enqueues an event in the Cooldown Queue

func (*CooldownQueue) Stop added in v0.0.8

func (q *CooldownQueue) Stop()

type CronTicker added in v0.0.83

type CronTicker struct {
	C chan time.Time
	// contains filtered or unexported fields
}

CronTicker is the struct returned to the user as a proxy to the ticker. The user can check the ticker channel for the next 'tick' via CronTicker.C (similar to the user of time.Timer).

func NewCronTicker added in v0.0.83

func NewCronTicker(schedule string) (*CronTicker, error)

NewCronTicker returns a CronTicker struct. You can check the ticker channel for the next tick by `CronTicker.Chan()`.

func (*CronTicker) Chan added in v0.0.83

func (c *CronTicker) Chan() <-chan time.Time

func (*CronTicker) Stop added in v0.0.83

func (c *CronTicker) Stop()

Stop sends the appropriate message on the control channel to kill the CronTicker goroutines. It's good practice to use `defer CronTicker.Stop()`.

type StdTicker added in v0.0.83

type StdTicker struct {
	*time.Ticker
}

func NewStdTicker added in v0.0.83

func NewStdTicker(d time.Duration) *StdTicker

func (*StdTicker) Chan added in v0.0.83

func (g *StdTicker) Chan() <-chan time.Time

type Ticker added in v0.0.83

type Ticker interface {
	Chan() <-chan time.Time
	Stop()
}

Jump to

Keyboard shortcuts

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