watcher

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default size for the cooldown queue
	DefaultQueueSize = 512
	// Default TTL for events put in the queue
	DefaultTTL = 1 * time.Second
)

Variables

View Source
var (
	ErrMissingWLID          = fmt.Errorf("missing WLID")
	ErrMissingSlug          = fmt.Errorf("missing slug")
	ErrMissingImageTag      = fmt.Errorf("missing image ID")
	ErrMissingImageID       = fmt.Errorf("missing image tag")
	ErrMissingContainerName = fmt.Errorf("missing container name")
)
View Source
var (
	ErrUnsupportedObject = errors.New("unsupported object type")
	ErrUnknownImageHash  = errors.New("unknown image hash")
)

Functions

This section is empty.

Types

type CooldownQueue added in v0.2.4

type CooldownQueue struct {
	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 forwards the event to its output channel and starts a cooldown for this event. If a client attempts to put the same event into the queue while the cooldown is running, the queue will silently drop the event. When the cooldown resets and a client puts the same event into the queue, it will be forwarded to the output channel

func NewCooldownQueue added in v0.2.4

func NewCooldownQueue(size int, cooldown time.Duration) *CooldownQueue

NewCooldownQueue returns a new Cooldown Queue

func (*CooldownQueue) Closed added in v0.2.4

func (q *CooldownQueue) Closed() bool

func (*CooldownQueue) Enqueue added in v0.2.4

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

Enqueue enqueues an event in the Cooldown Queue

func (*CooldownQueue) Stop added in v0.2.4

func (q *CooldownQueue) Stop()

type WatchHandler

type WatchHandler struct {
	SlugToImageID  maps.SafeMap[string, string] // map of <Slug> : string <image ID>
	WlidAndImageID mapset.Set[string]           // set of <wlid+imageID>
	// contains filtered or unexported fields
}

func NewWatchHandler

func NewWatchHandler(ctx context.Context, cfg config.IConfig, k8sAPI *k8sinterface.KubernetesApi, storageClient kssc.Interface, eventQueue *CooldownQueue) *WatchHandler

NewWatchHandler creates a new WatchHandler, initializes the maps and returns it

func (*WatchHandler) HandleSBOMFilteredEvents

func (wh *WatchHandler) HandleSBOMFilteredEvents(sfEvents <-chan watch.Event, producedCommands chan<- *apis.Command, errorCh chan<- error)

func (*WatchHandler) PodWatch

func (wh *WatchHandler) PodWatch(ctx context.Context, workerPool *ants.PoolWithFunc) error

func (*WatchHandler) SBOMFilteredWatch

func (wh *WatchHandler) SBOMFilteredWatch(ctx context.Context, workerPool *ants.PoolWithFunc)

SBOMFilteredWatch watches and processes changes on Filtered SBOMs

Jump to

Keyboard shortcuts

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