pacemaker

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MasterXPath = "//node/instance_attributes/nvpair[@value='LATEST']/../.."
	SyncXPath   = "//node/instance_attributes/nvpair[@value='STREAMING|SYNC']/../.."
	AsyncXPath  = "//node/instance_attributes/nvpair[@value='STREAMING|POTENTIAL']/../.."
)

Functions

func NewSubscriber

func NewSubscriber(options ...func(*subscriber)) *subscriber

NewSubscriber constructs a default subscriber configured to watch specific XML nodes inside the cib state.

func WatchNode

func WatchNode(alias, xpath, attribute string) func(*subscriber)

WatchNode creates an option for subscribers that activates watching of a specific attribute of the element found with the given xpath.

pacemaker.NewSubscriber(

pacemaker.WatchNode("master", "//resource[@id='master']", "name"),

)

would construct a subscriber that will watch for changes in the cib to the 'name' attribute of the resource element with id 'master'. The subscriber will trigger the handler registered on 'master' with the new values of the attribute.

func WithExecutor

func WithExecutor(e executor) func(*Pacemaker)

func WithLogger

func WithLogger(logger *logrus.Logger) func(*subscriber)

WithLogger registers a logger that subscriber will use for output

func WithTransform

func WithTransform(transform func(context.Context, string) (string, error)) func(*subscriber)

WithTransform allows application of a general function to the values that are observed to change. This can be used, for example, to resolve IP addresses from node names when watching for changes in cluster roles.

Types

type Pacemaker

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

Pacemaker wraps the executables provided by pacemaker, providing querying of the cib as well as running commands against crm.

func NewPacemaker

func NewPacemaker(options ...func(*Pacemaker)) *Pacemaker

func (Pacemaker) Get

func (p Pacemaker) Get(ctx context.Context, xpaths ...string) ([]*etree.Element, error)

Get returns nodes from the cibadmin XML output, extracted using the given XPaths. If we detect that pacemaker does not have quorum, then we error, as we should be able to rely on values being correct with respect to the quorate.

func (Pacemaker) Migrate

func (p Pacemaker) Migrate(ctx context.Context, to string) error

Migrate will issue a resource migration of msPostgresql to the given node

func (Pacemaker) ResolveAddress

func (p Pacemaker) ResolveAddress(ctx context.Context, nodeID string) (string, error)

ResolveAddress will find the IP address for a given node ID. Node IDs are numeric, but we'll typically extract them from XML that will yield strings. Given we'll be passing them as string executable arguments it makes sense to keep everything homomorphic.

func (Pacemaker) Unmigrate

func (p Pacemaker) Unmigrate(ctx context.Context) error

Unmigrate will remove constraints previously created by migrate

Jump to

Keyboard shortcuts

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