forked from latolukasz/beeorm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirty_event.go
50 lines (41 loc) · 929 Bytes
/
dirty_event.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
package beeorm
type DirtyEntityEvent interface {
ID() uint64
TableSchema() TableSchema
Added() bool
Updated() bool
Deleted() bool
}
type dirtyEvent struct {
I uint64
A string
E string
}
func EventDirtyEntity(e Event) DirtyEntityEvent {
data := dirtyEvent{}
e.Unserialize(&data)
schema := e.(*event).consumer.redis.engine.registry.GetTableSchema(data.E)
return &dirtyEntityEvent{id: data.I, schema: schema, added: data.A == "i", updated: data.A == "u", deleted: data.A == "d"}
}
type dirtyEntityEvent struct {
id uint64
added bool
updated bool
deleted bool
schema TableSchema
}
func (d *dirtyEntityEvent) ID() uint64 {
return d.id
}
func (d *dirtyEntityEvent) TableSchema() TableSchema {
return d.schema
}
func (d *dirtyEntityEvent) Added() bool {
return d.added
}
func (d *dirtyEntityEvent) Updated() bool {
return d.updated
}
func (d *dirtyEntityEvent) Deleted() bool {
return d.deleted
}