worker

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event added in v0.17.0

type Event struct {
	Reference string
	Type      EventType
}

Event describes a Worker event.

type EventType added in v0.17.0

type EventType string

EventType is the type of an event.

const (
	// EventTypeUpdated is emitted whenever data of an image is updated.
	EventTypeUpdated EventType = "updated"
	// EventTypeProcessed is emitted whenever an image was processed.
	EventTypeProcessed EventType = "processed"
	// EventTypeNewVersionAvailable is emitted whenever the latest available
	// version of an image changes.
	EventTypeNewVersionAvailable EventType = "newVersionAvailable"
)

type Queue added in v0.17.0

type Queue[T comparable] struct {
	// contains filtered or unexported fields
}

Queue is a queue data structure implementation useful for tracking jobs. It enables multiple producers to queue items for multiple consumers. Consumers will sleep whilst they're waiting for jobs. The implementation also provides token bucket-based rate limiting.

func NewQueue added in v0.17.0

func NewQueue[T comparable](burst int, tick time.Duration) *Queue[T]

NewQueue returns a new Queue. An initialized queue should be closed by calling Queue.Close

  • burst controls the target number of items that can be taken from the queue.
  • tick is the target mean time between items being taken from the queue.

func (*Queue[T]) AvailableBurst added in v0.17.0

func (q *Queue[T]) AvailableBurst() int

AvailableBurst returns the number of items that could currently be taken from the queue without being rate limited.

func (*Queue[T]) Close added in v0.17.0

func (q *Queue[T]) Close()

Close closes the queue and frees resources. Closing a queue will wake any waiting consumer and exit their pull loops. Continuing to use a closed queue will panic.

func (*Queue[T]) Collect added in v0.17.0

func (w *Queue[T]) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Queue[T]) Describe added in v0.17.0

func (w *Queue[T]) Describe(descs chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Queue[T]) Len added in v0.17.0

func (q *Queue[T]) Len() int

Len returns the size of the queue.

func (*Queue[T]) Pull added in v0.17.0

func (q *Queue[T]) Pull() iter.Seq[T]

Pull returns an iterator which will feed a consumer with items. The iterator will wait for new items if the queue is emptied and is only closed when the queue itself is closed, or when the consumer decides to stop processing items.

func (*Queue[T]) Push added in v0.17.0

func (q *Queue[T]) Push(items ...T)

Push puts one or more items at the end of the queue. Panics if the queue is closed.

type Worker

type Worker struct {
	*events.Hub[Event]
	// contains filtered or unexported fields
}

Worker processes raw container image entries, running the image workflow and storing the result to the state store. The worker produces events of the type Event.

func New

func New(httpClient httputil.Requester, store *store.Store, registryAuth *httputil.AuthMux) *Worker

func (*Worker) Collect

func (w *Worker) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Worker) Describe

func (w *Worker) Describe(descs chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Worker) ProcessRawImage

func (w *Worker) ProcessRawImage(ctx context.Context, reference oci.Reference) error

ProcessRawImage processes a raw image by the specified reference.

Jump to

Keyboard shortcuts

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