pachyderm: Index | Files

package watch

import ""

Package watch implements better watch semantics on top of etcd. See this issue for the reasoning behind the package:


Package Files

op.go watch.go

func CheckType Uses

func CheckType(template proto.Message, val interface{}) error

CheckType checks to make sure val has the same type as template, unless template is nil in which case it always returns nil.

type Event Uses

type Event struct {
    Key      []byte
    Value    []byte
    Type     EventType
    Rev      int64
    Ver      int64
    Err      error
    Template proto.Message

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

func (*Event) Unmarshal Uses

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

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

type EventType Uses

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
    // EventError happens when an error occurred

type OpOption Uses

type OpOption struct {
    Get   etcd.OpOption
    Watch etcd.OpOption

OpOption is a simple typedef for etcd.OpOption.

func WithFilterDelete Uses

func WithFilterDelete() OpOption

WithFilterDelete discards DELETE events from the watcher.

func WithFilterPut Uses

func WithFilterPut() OpOption

WithFilterPut discards PUT events from the watcher.

func WithSort Uses

func WithSort(sortBy etcd.SortTarget, sortOrder etcd.SortOrder) OpOption

WithSort specifies the sort to use for the watcher

type Watcher Uses

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

Watcher ...

func MakeWatcher Uses

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 Uses

func NewWatcher(ctx context.Context, client *etcd.Client, trimPrefix, prefix string, template proto.Message, opts ...OpOption) (Watcher, error)

NewWatcher watches a given etcd prefix for events.

Package watch imports 6 packages (graph) and is imported by 10 packages. Updated 2020-03-31. Refresh now. Tools for package owners.