-
Notifications
You must be signed in to change notification settings - Fork 93
/
util.go
63 lines (49 loc) · 943 Bytes
/
util.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
package kail
import (
"fmt"
"github.com/boz/kcache/nsname"
)
type EventSource interface {
Namespace() string
Name() string
Container() string
Node() string
}
type eventSource struct {
id nsname.NSName
container string
node string
}
func (es eventSource) Namespace() string {
return es.id.Namespace
}
func (es eventSource) Name() string {
return es.id.Name
}
func (es eventSource) Container() string {
return es.container
}
func (es eventSource) Node() string {
return es.node
}
func (es eventSource) String() string {
return fmt.Sprintf("%v/%v@%v",
es.id.Namespace, es.id.Name, es.container)
}
type Event interface {
Source() EventSource
Log() []byte
}
func newEvent(source EventSource, log []byte) Event {
return &event{source, log}
}
type event struct {
source EventSource
log []byte
}
func (e *event) Source() EventSource {
return e.source
}
func (e *event) Log() []byte {
return e.log
}