Documentation
¶
Index ¶
Constants ¶
const (
MAX_FILE_LEN = (1 << 10)
)
Variables ¶
This section is empty.
Functions ¶
func RegisterEtcdClient ¶
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.
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.