zookeeper

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2016 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 Client

type Client interface {
	Children(path string) ([]string, *zk.Stat, error)
	ChildrenW(string) ([]string, *zk.Stat, <-chan zk.Event, error)
	Create(path string, data []byte, flags int32, acl []zk.ACL) (string, error)
	Delete(path string, version int32) error
	Exists(path string) (bool, *zk.Stat, error)
	Get(path string) ([]byte, *zk.Stat, error)
	GetW(string) ([]byte, *zk.Stat, <-chan zk.Event, error)
	Set(path string, data []byte, version int32) (*zk.Stat, error)
}

Client in a interface that wraps zookeeper client methods.

type MockZK

type MockZK struct {
	Args        [][]interface{}
	ChildrenFn  func(path string) ([]string, *zk.Stat, error)
	ChildrenwFn func(path string) ([]string, *zk.Stat, <-chan zk.Event, error)
	CreateFn    func(path string, data []byte, flags int32, acl []zk.ACL) (string, error)
	DeleteFn    func(path string, version int32) error
	ExistsFn    func(path string) (bool, *zk.Stat, error)
	GetFn       func(path string) ([]byte, *zk.Stat, error)
	GetwFn      func(path string) ([]byte, *zk.Stat, <-chan zk.Event, error)
	SetFn       func(path string, data []byte, version int32) (*zk.Stat, error)
}

MockZK implements the zookeeper interface with overwritable implementation functions so that tests can supply their own behaviour. It is public so that it can be reused among other packages.

func NewMockZK

func NewMockZK() *MockZK

NewMockZK returns a MockZK that has default implementations for all overridable functions.

func (*MockZK) Children

func (mzk *MockZK) Children(path string) ([]string, *zk.Stat, error)

Children returns the files contained at a given path

func (*MockZK) ChildrenW

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

ChildrenW returns the files contained at a given path plus a channel that will contain a zk.Event when a change occurs at that path.

func (*MockZK) Create

func (mzk *MockZK) Create(path string, data []byte, flags int32, acl []zk.ACL) (string, error)

Create puts data into zookeeper into a path when a key did not previously exists at that path.

func (*MockZK) Delete

func (mzk *MockZK) Delete(path string, version int32) error

Delete removes a key from zookeeper that already exists.

func (*MockZK) Exists

func (mzk *MockZK) Exists(path string) (bool, *zk.Stat, error)

Exists returns true when a path exists; it also returns a zk.Stats which may be needed for future calls to operate on that same path.

func (*MockZK) Get

func (mzk *MockZK) Get(path string) ([]byte, *zk.Stat, error)

Get returns the data and zk.Stat for a given path.

func (*MockZK) GetW

func (mzk *MockZK) GetW(path string) ([]byte, *zk.Stat, <-chan zk.Event, error)

GetW returns the data and zk.Stat for a given path plus a channel that will populate with a zk.Event when the data at that path is altered.

func (*MockZK) Set

func (mzk *MockZK) Set(path string, data []byte, version int32) (*zk.Stat, error)

Set writes data into zookeeper at a given path where the path already contained data.

type PathTargeter

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

PathTargeter represents an object that connects to Zookeeper and queries a zk path for Vulcan scrape configurations for a specific zk path.

func NewPathTargeter

func NewPathTargeter(config *PathTargeterConfig) *PathTargeter

NewPathTargeter creates a new instance of PathTargeter.

func (*PathTargeter) Jobs

func (pt *PathTargeter) Jobs() <-chan []scraper.Job

Jobs implements scraper.JobWatcher interface. Returns a channel that feeds available jobs.

type PathTargeterConfig

type PathTargeterConfig struct {
	Conn Client
	Path string
}

PathTargeterConfig represents the configuration of a PathTargeter.

type Pool

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

Pool uses zookeeper as a backend to register a scraper's existence and watches zookeeper for changes in the list of active scrapers.

func NewPool

func NewPool(config *PoolConfig) (*Pool, error)

NewPool returns a new instance of Pool.

func (*Pool) Scrapers

func (p *Pool) Scrapers() <-chan []string

Scrapers returns a channel that sends a slice of active Scraper instances.

func (*Pool) Stop

func (p *Pool) Stop()

Stop signals the current Pool instance to stop running.

type PoolConfig

type PoolConfig struct {
	ID   string
	Conn Client
	Root string
}

PoolConfig represents the configuration of a Pool object.

type Targeter

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

Targeter uses zookeeper as a backend for configuring jobs that vulcan should scrape. The targeter watches the zookeeper path to react to new/changed/removed child nodes and their corresponding nodes.

func NewTargeter

func NewTargeter(config *TargeterConfig) (*Targeter, error)

NewTargeter returns a new instance of Targeter.

func (*Targeter) Stop

func (t *Targeter) Stop()

Stop signals the targeter instance to stop running.

func (*Targeter) Targets

func (t *Targeter) Targets() <-chan []scraper.Targeter

Targets implements scraper.Targeter interface. Returns a channel that feeds available jobs.

type TargeterConfig

type TargeterConfig struct {
	Conn Client
	Root string
}

TargeterConfig represents the configuration of a Targeter.

Jump to

Keyboard shortcuts

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