autopilot

package module
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 5 Imported by: 0

README

Autopilot

This library contains extended funcionality to use with Consul autopilot.

Functionality

  • Allows setting non voting servers. Those servers won't be included as voters. This allows you to add more servers without impacting the number os servers that are included in the voting decissions.
  • A zone can be specified to each server and if enabled, only one server per zone will act as voter.
  • The version of the voters can be upgraded automatically.

Usage

To use it you only need to do the following:

package main

import (
    "github.com/hashicorp/consul/agent/consul/autopilot"
    improvedAutopilot "github.com/jorgemarey/autopilot"
)

func example() *autopilot.Autopilot {
    var defaultDelegate autopilot.Delegate // construct the default autopilot.Delegate
    ...
    apDelegate := improvedAutopilot.New(nil, defaultDelegate) // you can provide a logger if needed
    return autopilot.NewAutopilot(nil, apDelegate, 10 * time.Second, 10 * time.Second)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Option) ra.Promoter

New will create a new promoter

Types

type ExtraConfig added in v0.4.0

type ExtraConfig struct {
	RedundancyZoneTag       string
	DisableUpgradeMigration bool
	UpgradeVersionTag       string
}

type ExtraServerInfo added in v0.4.0

type ExtraServerInfo struct {
	NonVoter bool
	Zone     string
	Version  string
}

type ImprovedPromoter added in v0.4.0

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

ImprovedPromoter is a new version of the promoter with improved funcionality

func (*ImprovedPromoter) CalculatePromotionsAndDemotions added in v0.4.0

func (p *ImprovedPromoter) CalculatePromotionsAndDemotions(config *ra.Config, state *ra.State) ra.RaftChanges

CalculatePromotionsAndDemotions return the changes

func (*ImprovedPromoter) FilterFailedServerRemovals added in v0.4.0

func (p *ImprovedPromoter) FilterFailedServerRemovals(config *ra.Config, state *ra.State, failed *ra.FailedServers) *ra.FailedServers

FilterFailedServerRemovals takes in the current state and structure outlining all the failed/stale servers and will return those failed servers which the promoter thinks should be allowed to be removed.

func (*ImprovedPromoter) GetNodeTypes added in v0.4.0

func (p *ImprovedPromoter) GetNodeTypes(config *ra.Config, state *ra.State) map[raft.ServerID]ra.NodeType

GetNodeTypes returns a map of ServerID to NodeType for all the servers which should have their NodeType field updated

func (*ImprovedPromoter) GetServerExt added in v0.4.0

func (p *ImprovedPromoter) GetServerExt(config *ra.Config, srvState *ra.ServerState) interface{}

GetServerExt returns some object that should be stored in the Ext field of the Server This value will not be used by the code in this repo but may be used by the other Promoter methods and the application utilizing autopilot. If the value returned is nil the extended state will not be updated.

func (*ImprovedPromoter) GetStateExt added in v0.4.0

func (p *ImprovedPromoter) GetStateExt(config *ra.Config, state *ra.State) interface{}

GetStateExt returns some object that should be stored in the Ext field of the State This value will not be used by the code in this repo but may be used by the other Promoter methods and the application utilizing autopilot. If the value returned is nil the extended state will not be updated.

type Option added in v0.4.2

type Option func(*ImprovedPromoter)

Option is an option to be used when creating a new Autopilot instance

func WithLogger added in v0.4.2

func WithLogger(logger hclog.Logger) Option

WithLogger returns an Option to set the Autopilot instance's logger

Jump to

Keyboard shortcuts

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