random

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

Random Picker

Type: random-picker

Selects endpoint(s) uniformly at random, ignoring any scores calculated by scorer plugins.

What it does

  1. Receives a list of ScoredEndpoint candidates.
  2. Shuffles the list in-place to randomize the order.
  3. Returns the top maxNumOfEndpoints candidates from the shuffled list.

Behavioral Intent

This picker provides strict uniform distribution of load across all available candidates. It ignores all scoring signals, making it immune to hot-spotting but unable to leverage optimization signals like cache affinity or predictable latency.

Inputs consumed

  • Consumes the list of ScoredEndpoint results (but ignores the Score field).

Configuration

The plugin config supports:

  • maxNumOfEndpoints (default 1)
    • The maximum number of endpoints to pick and return. Must be > 0. If more candidates are available than this limit, only the top subset is returned.

[!TIP] In most production scenarios, maxNumOfEndpoints is left at its default value of 1 to select a single target endpoint for the request.

Documentation

Overview

Package random implements a scheduling picker that selects endpoints uniformly at random, ignoring any scores calculated by scorer plugins.

For detailed behavioral intent and configuration, see the package README.

Index

Constants

View Source
const (
	// RandomPickerType is the registered name of the random picker plugin.
	RandomPickerType = "random-picker"
)

Variables

This section is empty.

Functions

func RandomPickerFactory

func RandomPickerFactory(name string, rawParameters *json.Decoder, _ fwkplugin.Handle) (fwkplugin.Plugin, error)

RandomPickerFactory defines the factory function for RandomPicker.

Types

type RandomPicker

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

RandomPicker picks random endpoint(s) from the list of candidates.

func NewRandomPicker

func NewRandomPicker(maxNumOfEndpoints int) *RandomPicker

NewRandomPicker initializes a new RandomPicker and returns its pointer.

func (*RandomPicker) Pick

func (p *RandomPicker) Pick(ctx context.Context, scoredEndpoints []*fwksched.ScoredEndpoint) *fwksched.ProfileRunResult

Pick selects random endpoint(s) from the list of candidates.

func (*RandomPicker) TypedName

func (p *RandomPicker) TypedName() fwkplugin.TypedName

TypedName returns the type and name tuple of this plugin instance.

func (*RandomPicker) WithName

func (p *RandomPicker) WithName(name string) *RandomPicker

WithName sets the name of the picker.

Jump to

Keyboard shortcuts

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