etcdClient

package
v0.0.0-11-10-2015.09-3... Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EtcdErrorCodeKeyExists = 105
View Source
const EtcdErrorCodeNotFound = 100

Etcd error codes

View Source
const SERVICE_TTL = 60

Variables

This section is empty.

Functions

func InitPlugin

func InitPlugin()

Register the plugin

Types

type EtcdPlugin

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

func (*EtcdPlugin) DelObj

func (self *EtcdPlugin) DelObj(key string) error

Remove an object

func (*EtcdPlugin) DeregisterService

func (self *EtcdPlugin) DeregisterService(serviceInfo api.ServiceInfo) error

Deregister a service This removes the service from the registry and stops the refresh groutine

func (*EtcdPlugin) GetLocalAddr

func (self *EtcdPlugin) GetLocalAddr() (string, error)

Return the local address where etcd is listening

func (*EtcdPlugin) GetObj

func (self *EtcdPlugin) GetObj(key string, retVal interface{}) error

Get an object

func (*EtcdPlugin) GetService

func (self *EtcdPlugin) GetService(name string) ([]api.ServiceInfo, error)

List all end points for a service

func (*EtcdPlugin) Init

func (self *EtcdPlugin) Init(machines []string) error

Initialize the etcd client

func (*EtcdPlugin) ListDir

func (self *EtcdPlugin) ListDir(key string) ([]string, error)

Get a list of objects in a directory

func (*EtcdPlugin) NewLock

func (self *EtcdPlugin) NewLock(name string, myId string, ttl uint64) (api.LockInterface, error)

Create a new lock

func (*EtcdPlugin) RegisterService

func (self *EtcdPlugin) RegisterService(serviceInfo api.ServiceInfo) error

Register a service Service is registered with a ttl for 60sec and a goroutine is created to refresh the ttl.

func (*EtcdPlugin) SetObj

func (self *EtcdPlugin) SetObj(key string, value interface{}) error

Save an object, create if it doesnt exist

func (*EtcdPlugin) WatchService

func (self *EtcdPlugin) WatchService(name string,
	eventCh chan api.WatchServiceEvent, stopCh chan bool) error

Watch for a service

type Lock

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

Lock object

func (*Lock) Acquire

func (self *Lock) Acquire(timeout uint64) error

Acquire a lock

func (*Lock) EventChan

func (self *Lock) EventChan() <-chan api.LockEvent

Return event channel

func (*Lock) GetHolder

func (self *Lock) GetHolder() string

Get current lock holder's Id

func (*Lock) IsAcquired

func (self *Lock) IsAcquired() bool

Check if the lock is acquired

func (*Lock) Kill

func (self *Lock) Kill() error

Note: This is for debug/test purposes only Stop a lock without releasing it. Let the etcd TTL expiry release it

func (*Lock) Release

func (self *Lock) Release() error

Release a lock

Jump to

Keyboard shortcuts

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