etcdlock

package
v3.7.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: LGPL-3.0 Imports: 7 Imported by: 12

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

Jump to

Keyboard shortcuts

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