-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
84 lines (71 loc) · 1.65 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package eventlog
import (
"context"
"io"
"time"
)
type EventReader interface {
io.Closer
seekReader
Read(limit int, timeout time.Duration) (items []Event, err error)
}
type CtxEventReader interface {
io.Closer
seekReader
ReadCtx(ctx context.Context, limit int, timeout time.Duration) (items []Event, err error)
}
type seekReader interface {
Offset() int64
Seek(offset int64) (int64, error)
}
type Event struct {
Date time.Time
TransactionStatus TransactionStatusType
TransactionDate time.Time
TransactionNumber int64
UserUuid string
User string
Computer string
Application ApplicationType
Connection int64
Event EventType
Severity SeverityType
Comment string
MetadataUuid string
Metadata string
Data interface{}
DataPresentation string
Server string
MainPort string
AddPort string
Session int64
//SessionDataSeparators []
Offset int64
Size int64
JournalFile string
JournalUUID string
}
type Objects interface {
ReferencedObjectValue(objectType int, id ...int) (value, uuid string)
ObjectValue(objectType int, id ...int) (value string)
}
var empty = struct{}{}
type EventManager struct {
Events chan Event
Poller Poller
reader EventReader
stop chan struct{}
}
func (m *EventManager) Start() {
if m.Poller == nil {
panic("manager: can't start without a poller")
}
}
func (m *EventManager) Stop() {
m.stop <- empty
}
func (m *EventManager) Poll(dest chan Event, stop chan struct{}) {
if m.Poller == nil {
panic("manager: can't start without a poller")
}
}