Documentation ¶
Index ¶
- Variables
- func NewSubscriber(options ...func(*subscriber)) *subscriber
- func WatchNode(alias, xpath, attribute string) func(*subscriber)
- func WithExecutor(e executor) func(*Pacemaker)
- func WithLogger(logger *logrus.Logger) func(*subscriber)
- func WithTransform(transform func(context.Context, string) (string, error)) func(*subscriber)
- type Pacemaker
Constants ¶
This section is empty.
Variables ¶
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 ¶
WithLogger registers a logger that subscriber will use for output
func WithTransform ¶
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 (Pacemaker) Get ¶
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 ¶
Migrate will issue a resource migration of msPostgresql to the given node
func (Pacemaker) ResolveAddress ¶
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.