zkdetect

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2015 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildWatcher

type ChildWatcher func(*Client, string)

interface for handling watcher event when zk.EventNodeChildrenChanged.

type Client

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

type Cluster

type Cluster interface {
	Detect(ClusterChanged) error
	Done() <-chan struct{}
	Cancel()
}

type ClusterChanged

type ClusterChanged interface {
	OnClusterChanged(*ClusterInfo)
}

type ClusterDetector

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

Detector uses ZooKeeper to detect new leading master.

func NewClusterDetector

func NewClusterDetector(zkurls string) (*ClusterDetector, error)

Internal constructor function

func (*ClusterDetector) Cancel

func (md *ClusterDetector) Cancel()

func (*ClusterDetector) Detect

func (md *ClusterDetector) Detect(f ClusterChanged) (err error)

the first call to Detect will kickstart a connection to zookeeper. a nil change listener may be spec'd, result of which is a detector that will still listen for master changes and record leaderhip changes internally but no listener would be notified. Detect may be called more than once, and each time the spec'd listener will be added to the list of those receiving notifications.

func (*ClusterDetector) Done

func (md *ClusterDetector) Done() <-chan struct{}

returns a chan that, when closed, indicates termination of the detector

type ClusterInfo

type ClusterInfo struct {
	Leader  *mesos.MasterInfo
	Masters *[]*mesos.MasterInfo
}

type Connector

type Connector interface {
	Close()
	Children(string) ([]string, *zk.Stat, error)
	ChildrenW(string) ([]string, *zk.Stat, <-chan zk.Event, error)
	Get(string) ([]byte, *zk.Stat, error)
}

Connector Interface to facade zk.Conn type since github.com/samuel/go-zookeeper/zk does not provide an interface for the zk.Conn object, this allows for mocking and easier testing.

type ErrorHandler

type ErrorHandler func(*Client, error)

interface for handling errors (session and watch related).

type Factory

type Factory interface {
	// contains filtered or unexported methods
}

Factory is an adapter to trap the creation of zk.Conn instances since the official zk API does not expose an interface for zk.Conn.

type MockClusterDetector

type MockClusterDetector struct {
	*ClusterDetector
	// contains filtered or unexported fields
}

func NewMockClusterDetector

func NewMockClusterDetector(zkurls string) (*MockClusterDetector, error)

func (*MockClusterDetector) ScheduleConnEvent

func (m *MockClusterDetector) ScheduleConnEvent(s zk.State)

func (*MockClusterDetector) ScheduleSessEvent

func (m *MockClusterDetector) ScheduleSessEvent(t zk.EventType)

func (*MockClusterDetector) Start

func (m *MockClusterDetector) Start()

type MockConnector

type MockConnector struct {
	mock.Mock
}

Impersontates a zk.Connection It implements interface Connector

func NewMockConnector

func NewMockConnector() *MockConnector

func (*MockConnector) Children

func (conn *MockConnector) Children(path string) ([]string, *zk.Stat, error)

func (*MockConnector) ChildrenW

func (conn *MockConnector) ChildrenW(path string) ([]string, *zk.Stat, <-chan zk.Event, error)

func (*MockConnector) Close

func (conn *MockConnector) Close()

func (*MockConnector) Get

func (conn *MockConnector) Get(path string) ([]byte, *zk.Stat, error)

type OnClusterChanged

type OnClusterChanged func(*ClusterInfo)

func (OnClusterChanged) OnClusterChanged

func (f OnClusterChanged) OnClusterChanged(ci *ClusterInfo)

Jump to

Keyboard shortcuts

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