package wrr

import "google.golang.org/grpc/internal/wrr"

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

Index

Types

type WRR

type WRR interface {
	// Add adds an item with weight to the WRR set.
	//
	// Add and Next need to be thread safe.
	Add(item interface{}, weight int64)
	// Next returns the next picked item.
	//
	// Add and Next need to be thread safe.
	Next() interface{}
}

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.

Source Files

edf.go random.go wrr.go

Version
v1.35.1
Published
Mar 12, 2021
Platform
js/wasm
Imports
4 packages
Last checked
10 minutes ago

Tools for package owners.