forked from sensu/sensu-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watcher.go
48 lines (43 loc) · 1.01 KB
/
watcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package store
const (
// WatchUnknown indicates that we received an unknown watch even tytpe
// from etcd.
WatchUnknown WatchActionType = iota
// WatchCreate indicates that an object was created.
WatchCreate
// WatchUpdate indicates that an object was updated.
WatchUpdate
// WatchDelete indicates that an object was deleted.
WatchDelete
// WatchError indicates that an error was encountered
WatchError
)
// WatchActionType indicates what type of change was made to an object in the store.
type WatchActionType int
// WatchEvent represents an event of a watched resource
type WatchEvent struct {
Type WatchActionType
Key string
Object []byte
Err error
}
// Watcher represents a generic watcher
type Watcher interface {
Result() <-chan WatchEvent
}
func (t WatchActionType) String() string {
var s string
switch t {
case WatchUnknown:
s = "Unknown"
case WatchCreate:
s = "Create"
case WatchDelete:
s = "Delete"
case WatchUpdate:
s = "Update"
case WatchError:
s = "Error"
}
return s
}