github.com/maier/nomad@v0.4.1-0.20161110003312-a9e3d0b8549d/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 EvalJob string 18 Job string 19 JobSummary string 20 Node string 21 Table string 22 } 23 24 // Items is a helper used to construct a set of watchItems. It deduplicates 25 // the items as they are added using map keys. 26 type Items map[Item]struct{} 27 28 // NewItems creates a new Items set and adds the given items. 29 func NewItems(items ...Item) Items { 30 wi := make(Items) 31 for _, item := range items { 32 wi.Add(item) 33 } 34 return wi 35 } 36 37 // Add adds an item to the watch set. 38 func (wi Items) Add(i Item) { 39 wi[i] = struct{}{} 40 }