watch

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2016 License: Apache-2.0 Imports: 5 Imported by: 10

Documentation

Overview

Package watch is a singleton registry of path -> etcd watches. It does the watching in a uniform manner, and uses provided functions to perform the specific work.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(w *Watcher)

Create a watch. Given a watcher, creates a watch and runs it in a goroutine, then registers it with the watch registry.

func Init

func Init(ec client.KeysAPI)

Init must be called before any watches can be established. Any attempt to create a watch before this is called will not yield an error but just log instead, without creating the watch. This should always be called before you're ready to use watches.

func Stop

func Stop(path string)

Stop a watch. Given a path, stops all the watchers for a given path (f.e., it expired).

Types

type Watch

type Watch struct {
	Key    string
	Config interface{}
}

Watch is a struct providing a generic way of passing key/value information from etcd that is already unmarshalled.

type Watcher

type Watcher struct {
	WatcherFunc
	Path         string
	Channel      chan *Watch
	StopChannel  chan struct{}
	ErrorChannel chan error
	StopOnError  bool
	Recursive    bool
}

Watcher is a struct that describes the various channels and data that comprise a successful watch on etcd.

Note in particular the Channel, which is an interface{}. The channel must be of type `chan` and it is expected that a listener exists for that channel elsewhere.

func NewWatcher

func NewWatcher(channel chan *Watch, path string, fun WatcherFunc) *Watcher

NewWatcher creates a basic Watcher with the channel, path, and WatcherFunc. NewWatcher will create the other channels and set recursive.

type WatcherFunc

type WatcherFunc func(*client.Response, *Watcher)

WatcherFunc is the function that's fired anytime the watch receives an event that is not an error. It is expected that the WatcherFunc send to the channel on success.

Jump to

Keyboard shortcuts

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