-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnotify.go
More file actions
50 lines (41 loc) · 1.01 KB
/
notify.go
File metadata and controls
50 lines (41 loc) · 1.01 KB
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
49
50
package memdb
type happening struct {
event Event
old interface{}
new interface{}
stats Stats
}
// Event is a type of event emitted by the class, see the On() method
type Event int
// String describes the event type
func (e Event) String() string {
switch e {
case Insert:
return "Insert event"
case Update:
return "Update event"
case Remove:
return "Remove event"
case Expiry:
return "Expiry event"
case Access:
return "Access event"
default:
break
}
return "Unknown event"
}
const (
// Insert Events happen when an item is inserted for the first time
Insert Event = iota
// Update Events happen when an existing item is replaced with an new item
Update
// Remove Events happen when an existing item is deleted
Remove
// Expiry Events happen when items are removed due to being expired
Expiry
// Access Events happen when items are read
Access
)
// NotifyFunc is an event receiver that gets called when events happen
type NotifyFunc func(event Event, old, new interface{}, stats Stats)