github.com/ryanslade/nomad@v0.2.4-0.20160128061903-fc95782f2089/nomad/watch/watch.go (about) 1 package watch 2 3 // The watch package provides a means of describing a watch for a blocking 4 // query. It is exported so it may be shared between Nomad's RPC layer and 5 // the underlying state store. 6 7 // Item describes the scope of a watch. It is used to provide a uniform 8 // input for subscribe/unsubscribe and notification firing. Specifying 9 // multiple fields does not place a watch on multiple items. Each Item 10 // describes exactly one scoped watch. 11 type Item struct { 12 Alloc string 13 AllocEval string 14 AllocJob string 15 AllocNode string 16 Eval string 17 Job string 18 Node string 19 Table string 20 } 21 22 // Items is a helper used to construct a set of watchItems. It deduplicates 23 // the items as they are added using map keys. 24 type Items map[Item]struct{} 25 26 // NewItems creates a new Items set and adds the given items. 27 func NewItems(items ...Item) Items { 28 wi := make(Items) 29 for _, item := range items { 30 wi.Add(item) 31 } 32 return wi 33 } 34 35 // Add adds an item to the watch set. 36 func (wi Items) Add(i Item) { 37 wi[i] = struct{}{} 38 }