Documentation ¶
Index ¶
- Constants
- type Option
- type PriorityQueue
- func (p *PriorityQueue) Add(sub *appsapi.Subscription) error
- func (p *PriorityQueue) AddUnschedulableIfNotPresent(sInfo *framework.SubscriptionInfo) error
- func (p *PriorityQueue) Close()
- func (p *PriorityQueue) Delete(sub *appsapi.Subscription) error
- func (p *PriorityQueue) Pop() (*framework.SubscriptionInfo, error)
- func (p *PriorityQueue) Run()
- func (p *PriorityQueue) Update(oldSub, newSub *appsapi.Subscription) error
- type SchedulingQueue
Constants ¶
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 WithInitialBackoffDuration ¶
WithInitialBackoffDuration sets initial backoff duration for PriorityQueue,
func WithMaxBackoffDuration ¶
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) 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 ¶
func (p *PriorityQueue) Pop() (*framework.SubscriptionInfo, error)
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.