eventqueue

package
v1.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	EventType rules.EventType              `json:"eventType"`
	RuleID    rules.RuleID                 `json:"ruleID"`
	Objects   []*unstructured.Unstructured `json:"objects"`
	// contains filtered or unexported fields
}

Event struct holds all information related to an event.

type EventQueue

type EventQueue struct {
	workqueue.DelayingInterface
	// contains filtered or unexported fields
}

EventQueue wraps around the workqueue.DelayingInterface and provides additional functionality. Adds functionality to process and retry items if failed. TODO: Add persistence of the queue. Currently queue is lost in case of crash.

func New

func New(executor QueueExecutor, queueOpts Opts) *EventQueue

New creates a New EventQueue and returns the pointer to it.

func (*EventQueue) StartQueueWorkerPool

func (eq *EventQueue) StartQueueWorkerPool()

StartQueueWorkerPool will start a pool of workers to process queue items. Blocks until all workers have finished. The number of workers is determined by the workerCount parameter. Closing the queue will cause the queue to be drained and all workers to exit.

type Opts

type Opts struct {
	WorkerCount  int
	MaxTryCount  int
	RequeueDelay time.Duration
}

Opts holds the configuration options for the EventQueue. WorkerCount is the number of workers to start. MaxTryCount is the maximum number of times an item will be retried. RequeueDelay is the delay in seconds before an item is retried.

type QueueExecutor

type QueueExecutor interface {
	Execute(event *Event) error
}

QueueExecutor all queue executors must implement this interface. Execute method will be called for each item in the queue.

Jump to

Keyboard shortcuts

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