queue

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultInitialBackoffDuration is the default value for the initial backoff duration
	DefaultInitialBackoffDuration time.Duration = 1 * time.Second
	// DefaultMaxBackoffDuration is the default value for the max backoff duration
	DefaultMaxBackoffDuration time.Duration = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*priorityQueueOptions)

Option configures a PriorityQueue

func WithClock

func WithClock(clock clock.Clock) Option

WithClock sets clock for PriorityQueue, the default clock is util.RealClock.

func WithInitialBackoffDuration

func WithInitialBackoffDuration(duration time.Duration) Option

WithInitialBackoffDuration sets initial backoff duration for PriorityQueue,

func WithMaxBackoffDuration

func WithMaxBackoffDuration(duration time.Duration) Option

WithMaxBackoffDuration sets max backoff duration for PriorityQueue,

type PriorityQueue

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

func NewPriorityQueue

func NewPriorityQueue(
	lessFn framework.LessFunc,
	opts ...Option,
) *PriorityQueue

NewPriorityQueue creates a PriorityQueue object.

func (*PriorityQueue) Add

func (p *PriorityQueue) Add(sub *appsapi.Subscription) error

Add adds a subscription to the active queue. It should be called only when a new subscription is added so there is no chance the subscription is already in any queues

func (*PriorityQueue) AddUnschedulableIfNotPresent

func (p *PriorityQueue) AddUnschedulableIfNotPresent(sInfo *framework.SubscriptionInfo) error

AddUnschedulableIfNotPresent inserts a subscription that cannot be schedule directly into the backoff queue. TODO: add a subscription that cannot be schedule into a unschedulableSubscriptions queue and wait for subscribe-related events to occur, and then trigger the sub to move from unschedulableSubscriptions to the backoff queue.

func (*PriorityQueue) Close

func (p *PriorityQueue) Close()

Close closes the priority queue.

func (*PriorityQueue) Delete

func (p *PriorityQueue) Delete(sub *appsapi.Subscription) error

Delete deletes the item from either of the two queues. It assumes the subscription is only in one queue.

func (*PriorityQueue) Pop

Pop removes the head of the active queue and returns it. It blocks if the activeQ is empty and waits until a new item is added to the queue. It increments scheduling cycle when a subscription is popped.

func (*PriorityQueue) Run

func (p *PriorityQueue) Run()

Run starts the goroutine to pump from backoffQ to activeQ

func (*PriorityQueue) Update

func (p *PriorityQueue) Update(oldSub, newSub *appsapi.Subscription) error

Update update old sub and new sub

type SchedulingQueue

type SchedulingQueue interface {

	// Run starts the goroutines managing the queue.
	Run()

	// Pop pop out a subscription scheduling info
	Pop() (*framework.SubscriptionInfo, error)

	// AddUnschedulableIfNotPresent inserts a subscription that cannot be schedule directly into
	// the backoff queue.
	AddUnschedulableIfNotPresent(sInfo *framework.SubscriptionInfo) error

	// Add adds a subscription to the active queu
	Add(sub *appsapi.Subscription) error

	Update(oldSub, newSub *appsapi.Subscription) error

	Delete(sub *appsapi.Subscription) error

	// Close closes the SchedulingQueue so that the goroutine which is
	// waiting to pop items can exit gracefully.
	Close()
}

SchedulingQueue is an interface for a queue to store subscriptions waiting to be scheduled

func NewSchedulingQueue

func NewSchedulingQueue(lessFn framework.LessFunc, opts ...Option) SchedulingQueue

NewSchedulingQueue initializes a priority queue as a new scheduling queue.

Jump to

Keyboard shortcuts

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