forked from ekanite/ekanite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.go
More file actions
37 lines (30 loc) · 646 Bytes
/
event.go
File metadata and controls
37 lines (30 loc) · 646 Bytes
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
package ekanite
import (
"fmt"
"github.com/ekanite/ekanite/input"
)
// Event is a log message that can be indexed.
type Event struct {
*input.Event
}
// NewEvent retuns a new Event.
func NewEvent() *Event {
return &Event{}
}
// ID returns a unique ID for the event.
func (e Event) ID() DocID {
return DocID(fmt.Sprintf("%016x%016x",
uint64(e.ReferenceTime().UnixNano()), uint64(e.Sequence)))
}
// Data returns the indexable data.
func (e Event) Data() interface{} {
return struct {
Message string
}{
Message: e.Text,
}
}
// Source returns the original received data.
func (e Event) Source() []byte {
return []byte(e.Text)
}