Documentation
¶
Index ¶
Constants ¶
const ( // DefaultBindingMaxInUnschedulableBindingsDuration is the default value for the maximum // time a binding can stay in unschedulableBindings. If a binding stays in unschedulableBindings // for longer than this value, the binding will be moved from unschedulableBindings to // backoffQ or activeQ. If this value is empty, the default value (5min) // will be used. DefaultBindingMaxInUnschedulableBindingsDuration = 5 * time.Minute // DefaultBindingInitialBackoffDuration is the default value for the initial backoff duration // for unschedulable bindings. DefaultBindingInitialBackoffDuration = 1 * time.Second // DefaultBindingMaxBackoffDuration is the default value for the max backoff duration // for unschedulable bindings. DefaultBindingMaxBackoffDuration = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func BindingKeyFunc ¶
func BindingKeyFunc(bindingInfo *QueuedBindingInfo) string
BindingKeyFunc is the key mapping function of QueuedBindingInfo.
func Less ¶
func Less(bInfo1, bInfo2 *QueuedBindingInfo) bool
Less is the function used by the activeQ heap algorithm to sort bindings. It sorts bindings based on their priority. When priorities are equal, it uses QueuedBindingInfo.timestamp.
Types ¶
type ActiveQueue ¶
type ActiveQueue interface {
Push(bindingInfo *QueuedBindingInfo)
Pop() (*QueuedBindingInfo, bool)
Len() int
Done(bindingInfo *QueuedBindingInfo)
Has(key string) bool
ShutDown()
}
ActiveQueue defines the interface of activeQ related operations.
func NewActiveQueue ¶
func NewActiveQueue(metricRecorder metrics.MetricRecorder) ActiveQueue
NewActiveQueue builds a instance of ActiveQueue.
type Option ¶
type Option func(*schedulingQueueOptions)
Option configures a PriorityQueue
func WithBindingInitialBackoffDuration ¶
WithBindingInitialBackoffDuration sets binding initial backoff duration for SchedulingQueue.
func WithBindingMaxBackoffDuration ¶
WithBindingMaxBackoffDuration sets binding max backoff duration for SchedulingQueue.
func WithBindingMaxInUnschedulableBindingsDuration ¶
WithBindingMaxInUnschedulableBindingsDuration sets bindingMaxInUnschedulableBindingsDuration for SchedulingQueue.
type QueuedBindingInfo ¶
type QueuedBindingInfo struct {
NamespacedKey string
// The priority of ResourceBinding.
Priority int32
// The time binding added to the scheduling queue.
Timestamp time.Time
// The time when the binding is added to the queue for the first time. The binding may be added
// back to the queue multiple times before it's successfully scheduled.
// It shouldn't be updated once initialized.
InitialAttemptTimestamp *time.Time
// Number of schedule attempts before successfully scheduled.
// It's used to record the attempts metric and calculate the backoff time this Binding is obliged to get before retrying.
Attempts int
}
QueuedBindingInfo is a Binding wrapper with additional information related to the binding's status in the scheduling queue, such as the timestamp when it's added to the queue.
func (*QueuedBindingInfo) DeepCopy ¶
func (qbi *QueuedBindingInfo) DeepCopy() *QueuedBindingInfo
DeepCopy returns a deep copy of the QueuedBindingInfo object.
type SchedulingQueue ¶
type SchedulingQueue interface {
// Push pushes an new binding to activeQ.
Push(bindingInfo *QueuedBindingInfo)
// PushUnschedulableIfNotPresent pushes an unschedulable binding back to scheduling queue.
PushUnschedulableIfNotPresent(bindingInfo *QueuedBindingInfo)
// PushBackoffIfNotPresent pushes an failed binding back to scheduling queue.
PushBackoffIfNotPresent(bindingInfo *QueuedBindingInfo)
// Pop removes the head of the queue and returns it. It blocks if the
// queue is empty and waits until a new binding is added to the queue.
Pop() (*QueuedBindingInfo, bool)
// Done must be called for binding returned by Pop. This allows the queue to
// keep track of which bindings are currently being processed.
Done(bindingInfo *QueuedBindingInfo)
// Len returns the length of activeQ.
Len() int
// Forget indicates that an item is finished being retried. Doesn't matter whether it's for perm failing
// or for success, we'll remove it from backoffQ, but you still have to call `Done` on the queue.
Forget(bindingInfo *QueuedBindingInfo)
// Run starts the goroutines managing the queue.
Run()
// 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 bindings waiting to be scheduled. The interface follows a pattern similar to cache.FIFO and cache.Heap and makes it easy to use those data structures as a SchedulingQueue.
func NewSchedulingQueue ¶
func NewSchedulingQueue(opts ...Option) SchedulingQueue
NewSchedulingQueue builds a SchedulingQueue instance.
type UnschedulableBindings ¶
type UnschedulableBindings struct {
// contains filtered or unexported fields
}
UnschedulableBindings holds bindings that cannot be scheduled. This data structure is used to implement unschedulableBindings.