p2c

package
v0.0.0-...-9a2c5cd Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package p2c helps you to to select two nodes randomly from all available nodes and then select a less loaded node based on the load of these two nodes (in other words - "Power of Two"). Algorithm is an improved random algorithm that avoids the worst selection and load imbalances. The P2C approach is not as effective on a single load balancer, but it deftly avoids the bad‑case “herd behavior” that can occur when you scale out to a number of independent load balancers.

Index

Constants

View Source
const (

	// Name is p2c(Pick of 2 choices) balancer name
	Name = "p2c"
)

Variables

This section is empty.

Functions

func New

func New(opts ...Option) registry.Selector

New creates a p2c selector.

func NewBuilder

func NewBuilder(opts ...Option) registry.Builder

NewBuilder returns a selector builder with p2c balancer

Types

type Balancer

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

Balancer is p2c selector.

func (*Balancer) Pick

Pick pick a node.

type Builder

type Builder struct{}

Builder is p2c builder

func (*Builder) Build

func (b *Builder) Build() registry.Balancer

Build creates Balancer

type Option

type Option func(o *options)

Option is p2c builder option.

Jump to

Keyboard shortcuts

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