etcd

package
v0.0.0-...-a26ad45 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2016 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MAX_FILE_LEN = (1 << 10)
)

Variables

This section is empty.

Functions

func RegisterEtcdClient

func RegisterEtcdClient(etcdClient *etcd.Client)

Register the etcd watcher with the go-file mechanisms.

Types

type EtcdReader

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

Reader to read a file from etcd.

Upon the first call to Read(), the entire contents of the file are returned. Subsequent calls will return an EOF error.

func NewEtcdReader

func NewEtcdReader(etcdClient *etcd.Client, path string) (*EtcdReader, error)

Create a new EtcdReader to read the file "path" from the client "etcdClient".

func (*EtcdReader) Close

func (rd *EtcdReader) Close() error

Define the file handle as closed, just in case.

func (*EtcdReader) Read

func (rd *EtcdReader) Read(p []byte) (int, error)

Read the contents of the wrapped file and etcd and return them.

type EtcdWatcher

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

Watcher for an individual etcd key, or prefix.

func NewEtcdWatcher

func NewEtcdWatcher(etcdClient *etcd.Client, path string,
	cb func(string, io.ReadCloser)) (*EtcdWatcher, error)

Create a new etcd watcher on the client "etcdClient". Listen for changes of the key / prefix "path", and deliver notifications to "callback". Any errors will be returned on the given error channel "errchan.

The callback function will receive the path of the actually modified key as the first parameter and a ReadCloser with the files contents as the second. The ReadCloser does not do any significant work until Read() is invoked for the first time, so it is safe to ignore it and just use this to be notified of file modifications.

func (*EtcdWatcher) ErrChan

func (w *EtcdWatcher) ErrChan() chan error

Retrieve the error channel associated with the watcher. It will stream a list of all errors created while watching.

func (*EtcdWatcher) Shutdown

func (w *EtcdWatcher) Shutdown() error

Shut down the listener after the next change. There's no way to stop it immediately, though.

type EtcdWatcherCreator

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

etcd file watcher implementation.

func (*EtcdWatcherCreator) Watch

func (e *EtcdWatcherCreator) Watch(
	file *url.URL, cb func(string, io.ReadCloser)) (
	file.Watcher, error)

Create a new watcher object for watching for notifications on the given URL.

type EtcdWriter

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

etcd writer object. Unlike most other writers, all file contents are only written when the writer is closed.

func NewEtcdWriter

func NewEtcdWriter(etcdClient *etcd.Client, path string) *EtcdWriter

Create a new etcd writer for the file given at "path", on the etcd service "etcdClient". Any contents in this writer will be written on Close().

func (*EtcdWriter) Close

func (wr *EtcdWriter) Close() error

Write the contents collected so far to the file in etcd.

func (*EtcdWriter) Write

func (wr *EtcdWriter) Write(b []byte) (n int, err error)

Write the bytes given in "b" to the file on etcd. If the total size of the file exceeds 1MB, an "invalid" error (os.ErrInvalid) will be returned.

Jump to

Keyboard shortcuts

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