Help us shape the future of Go! Take the 2026 Go Developer Survey

gxselector

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFails = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SW

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

func NewSW

func NewSW(maxFails int) *SW

func (*SW) Add

func (w *SW) Add(item interface{}, weight int)

Add a weighted server.

func (*SW) All

func (w *SW) All() map[interface{}]int

All returns all items.

func (*SW) Next

func (w *SW) Next() SWItem

Next returns next selected server.

func (*SW) Release

func (w *SW) Release(item SWItem, success bool)

func (*SW) RemoveAll

func (w *SW) RemoveAll()

RemoveAll removes all weighted items.

func (*SW) Reset

func (w *SW) Reset()

Reset resets all current weights.

type SWItem

type SWItem interface {
	Index() int        // its index in all items
	Item() interface{} // ite primary item
}

Jump to

Keyboard shortcuts

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