picker

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package picker gets list of healthy nodes and pick one of them randomly based on weight

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

Node has a part from config and alive + changed for status monitoring

type RandomWeighted

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

RandomWeighted implements picker with the random, weighted selection

func NewRandomWeighted

func NewRandomWeighted(nodes config.NodesMap, refresh, timeout time.Duration, failBackURL string) *RandomWeighted

NewRandomWeighted makes new picker. Activate alive update thread

func (*RandomWeighted) Nodes

func (w *RandomWeighted) Nodes() map[string][]Node

Nodes return list of all current nodes

func (*RandomWeighted) Pick

func (w *RandomWeighted) Pick(svc, resource string) (resURL string, node Node, err error)

Pick random node with weights

func (*RandomWeighted) Status added in v1.2.0

func (w *RandomWeighted) Status() (ok bool, failed []string)

Status return status of all nodes, true if all nodes are alive, false if at least one is dead and return list of dead nodes

Jump to

Keyboard shortcuts

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