selector

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomSelectMultiple

func RandomSelectMultiple(
	endpoints protocol.EndpointAddrList,
	numEndpoints uint,
) protocol.EndpointAddrList

RandomSelectMultiple performs Fisher-Yates shuffle for random selection without replacement. This is a shared utility to avoid code duplication across QoS services. Ref: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

Parameters: - endpoints: The list of endpoints to select from - numEndpoints: The number of endpoints to select

Returns a new slice containing randomly selected endpoints. If numEndpoints is greater than len(endpoints), returns all endpoints.

func SelectEndpointsWithDiversity

func SelectEndpointsWithDiversity(
	logger polylog.Logger,
	availableEndpoints protocol.EndpointAddrList,
	numEndpoints uint,
) protocol.EndpointAddrList

SelectEndpointsWithDiversity selects endpoints with TLD diversity preference.

This helper is useful and necessary when used in conjunction with parallel requests. When multiple parallel requests are fired off, it is wasteful to send them all to the same TLD. Sending the request to different providers increases the likelihood of a successful request being returned to the user.

Types

This section is empty.

Jump to

Keyboard shortcuts

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