watch

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package watch implements better watch semantics on top of etcd. See this issue for the reasoning behind the package: https://github.com/coreos/etcd/issues/7362

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Key       []byte
	Value     []byte
	PrevKey   []byte
	PrevValue []byte
	Type      EventType
	Rev       int64
	Err       error
}

Event is an event that occurred to an item in etcd.

func (*Event) Unmarshal

func (e *Event) Unmarshal(key *string, val proto.Unmarshaler) error

Unmarshal unmarshals the item in an event into a protobuf message.

func (*Event) UnmarshalPrev added in v1.5.0

func (e *Event) UnmarshalPrev(key *string, val proto.Unmarshaler) error

UnmarshalPrev unmarshals the prev item in an event into a protobuf message.

type EventType

type EventType int

EventType is the type of event

const (
	// EventPut happens when an item is added
	EventPut EventType = iota
	// EventDelete happens when an item is removed
	EventDelete
	// EventError happens when an error occurred
	EventError
)

type Watcher

type Watcher interface {
	// Watch returns a channel that delivers events
	Watch() <-chan *Event
	// Close this channel when you are done receiving events
	Close()
}

Watcher ...

func MakeWatcher

func MakeWatcher(eventCh chan *Event, done chan struct{}) Watcher

MakeWatcher returns a Watcher that uses the given event channel and done channel internally to deliver events and signal closure, respectively.

func NewWatcher

func NewWatcher(ctx context.Context, client *etcd.Client, prefix string) (Watcher, error)

NewWatcher watches a given etcd prefix for events.

func NewWatcherWithPrev added in v1.5.0

func NewWatcherWithPrev(ctx context.Context, client *etcd.Client, prefix string) (Watcher, error)

NewWatcherWithPrev is like NewWatcher, except that the returned events include the previous version of the values.

Jump to

Keyboard shortcuts

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