Documentation

Overview

Package etcdlock Master election using etcd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MasterEvent

type MasterEvent struct {
	Type   MasterEventType // event type
	Master string          // identity of the lock holder
	Error  error
}

MasterEvent represents a single event sent on the events channel.

type MasterEventType

type MasterEventType int

MasterEventType Various event types for the events channel.

const (
	//MasterAdded this node has the lock.
	MasterAdded MasterEventType = iota
	//MasterDeleted MasterDeleted
	MasterDeleted
	//MasterModified MasterModified
	MasterModified
	//MasterError MasterError
	MasterError
)

type MasterInterface

type MasterInterface interface {
	// Start the election and attempt to acquire the lock. If acquired, the
	// lock is refreshed periodically based on the ttl.
	Start()

	// Stops watching the lock. Closes the events channel.
	Stop()

	// Returns the event channel used by the etcd lock.
	EventsChan() <-chan MasterEvent

	// Method to get the current lockholder. Returns "" if free.
	GetHolder() string
}

MasterInterface Interface used by the etcd master lock clients.

func CreateMasterLock

func CreateMasterLock(etcdEndpoints []string, election string, prop string, ttl int64) (MasterInterface, error)

CreateMasterLock create master lock

Source Files