wr

package
v1.0.25 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

wr is Weighted random

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNode

func NewNode(host string, port, weight int, meta selector.Meta) selector.Node

Types

type Node

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

func (*Node) Address

func (n *Node) Address() string

func (*Node) Meta

func (n *Node) Meta() selector.Meta

func (*Node) Statistics

func (n *Node) Statistics() selector.Statistics

func (*Node) Weight

func (n *Node) Weight() int

type Selector

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

func NewSelector

func NewSelector(opts ...SelectorOption) *Selector

func (*Selector) AddNode

func (s *Selector) AddNode(node selector.Node) (err error)

func (*Selector) AfterHandle

func (s *Selector) AfterHandle(address string, err error)

func (*Selector) DeleteNode

func (s *Selector) DeleteNode(host string, port int) (err error)

func (*Selector) GetNode

func (s *Selector) GetNode(host string, port int) (node selector.Node, ok bool)

func (*Selector) GetNodes

func (s *Selector) GetNodes() (nodes []selector.Node, err error)

func (*Selector) Select

func (s *Selector) Select() (node selector.Node, err error)

func (*Selector) ServiceName

func (s *Selector) ServiceName() string

type SelectorOption

type SelectorOption func(*Selector)

func WithServiceName

func WithServiceName(name string) SelectorOption

Jump to

Keyboard shortcuts

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