-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
61 lines (46 loc) · 929 Bytes
/
events.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
49
50
51
52
53
54
55
56
57
58
59
60
61
package levelup
import "time"
type EventType int
const (
None EventType = iota
Close
Shutdown
)
type Action int
const (
CreateEvent Action = iota
UpdateEvent
DeleteEvent
RollbackEvent
)
type EventScope int
const (
RecordScope EventScope = iota
CollectionScope
DatabaseScope
)
type Event struct {
CreatedAt time.Time
Action Action
Type EventType
Record *Record
Collection *Collection
Database *Database
//Differences []Difference
// Rollback
// TODO: Later we can simplify by removing rollback history if required
//RewindEvent *Log
}
//type Difference struct {
// Offset int
// Length int
// NewValue []byte
// OldValue []byte
//}
type Events struct {
Load func(database Database)
Unload func(database Database)
Writing func(database Database) (event Event)
Rewinding func(database Database) (event Event)
Tick func(now time.Time) (delay time.Duration, event Event)
}