servers

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package servers provides an interface for choosing Servers to communicate with from a Nomad Client perspective. The package does not provide any API guarantees and should be called only by `hashicorp/nomad`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(logger hclog.Logger, shutdownCh chan struct{}, connPoolPinger Pinger) (m *Manager)

New is the only way to safely create a new Manager struct.

func (*Manager) FindServer

func (m *Manager) FindServer() *Server

FindServer returns a server to send an RPC too. If there are no servers, nil is returned.

func (*Manager) GetServers

func (m *Manager) GetServers() Servers

GetServers returns a copy of the current list of servers.

func (*Manager) NotifyFailedServer

func (m *Manager) NotifyFailedServer(s *Server)

NotifyFailedServer marks the passed in server as "failed" by rotating it to the end of the server list.

func (*Manager) NumNodes

func (m *Manager) NumNodes() int32

NumNodes returns the number of approximate nodes in the cluster.

func (*Manager) NumServers

func (m *Manager) NumServers() int

NumServers returns the total number of known servers whether healthy or not.

func (*Manager) RebalanceServers

func (m *Manager) RebalanceServers()

RebalanceServers shuffles the order in which Servers will be contacted. The function will shuffle the set of potential servers to contact and then attempt to contact each server. If a server successfully responds it is used, otherwise it is rotated such that it will be the last attempted server.

func (*Manager) ResetRebalanceTimer

func (m *Manager) ResetRebalanceTimer()

ResetRebalanceTimer resets the rebalance timer. This method exists for testing and should not be used directly.

func (*Manager) SetNumNodes

func (m *Manager) SetNumNodes(n int32)

SetNumNodes stores the number of approximate nodes in the cluster.

func (*Manager) SetServers

func (m *Manager) SetServers(servers Servers) bool

SetServers sets the servers and returns if the new server list is different than the existing server set

func (*Manager) Start

func (m *Manager) Start()

Start is used to start and manage the task of automatically shuffling and rebalancing the list of Nomad servers in order to distribute load across all known and available Nomad servers.

type Pinger

type Pinger interface {
	Ping(addr net.Addr) error
}

Pinger is an interface for pinging a server to see if it is healthy.

type Server

type Server struct {
	// Addr is the resolved address of the server
	Addr net.Addr

	sync.Mutex
	// contains filtered or unexported fields
}

Server contains the address of a server and metadata that can be used for choosing a server to contact.

func (*Server) Copy

func (s *Server) Copy() *Server

func (*Server) Equal

func (s *Server) Equal(o *Server) bool

func (*Server) String

func (s *Server) String() string

type Servers

type Servers []*Server

func (Servers) Equal

func (s Servers) Equal(o Servers) bool

Equal returns if the two server lists are equal, including the ordering.

func (Servers) Sort

func (s Servers) Sort()

func (Servers) String

func (s Servers) String() string

Jump to

Keyboard shortcuts

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