wrr

package
v1.69.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package wrr contains the interface and common implementations of wrr algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WRR

type WRR interface {
	// Add adds an item with weight to the WRR set. Add must be only called
	// before any calls to Next.
	Add(item any, weight int64)
	// Next returns the next picked item.
	//
	// Next needs to be thread safe. Add may not be called after any call to
	// Next.
	Next() any
}

WRR defines an interface that implements weighted round robin.

func NewEDF

func NewEDF() WRR

NewEDF creates Earliest Deadline First (EDF) (https://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling) implementation for weighted round robin. Each pick from the schedule has the earliest deadline entry selected. Entries have deadlines set at current time + 1 / weight, providing weighted round robin behavior with O(log n) pick time.

func NewRandom

func NewRandom() WRR

NewRandom creates a new WRR with random.

Jump to

Keyboard shortcuts

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