-
Notifications
You must be signed in to change notification settings - Fork 11
/
ik.go
209 lines (171 loc) · 4.01 KB
/
ik.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package ik
import (
"github.com/moriyoshi/ik/task"
"io"
"math/rand"
"net/http"
)
type FluentRecord struct {
Tag string
Timestamp uint64
Data map[string]interface{}
}
type TinyFluentRecord struct {
Timestamp uint64
Data map[string]interface{}
}
type FluentRecordSet struct {
Tag string
Records []TinyFluentRecord
}
type Port interface {
Emit(recordSets []FluentRecordSet) error
}
type Spawnee interface {
Run() error
Shutdown() error
}
type PluginInstance interface {
Spawnee
Factory() Plugin
}
type Input interface {
PluginInstance
Port() Port
}
type Output interface {
PluginInstance
Port
}
type MarkupAttributes int
const (
Red = 0x00001
Green = 0x00002
Yellow = 0x00003
Blue = 0x00004
Magenta = 0x00005
Cyan = 0x00006
White = 0x00007
Embolden = 0x10000
Underlined = 0x20000
)
type MarkupChunk struct {
Attrs MarkupAttributes
Text string
}
type Markup struct {
Chunks []MarkupChunk
}
type ScoreValueFetcher interface {
PlainText(PluginInstance) (string, error)
Markup(PluginInstance) (Markup, error)
}
type Disposable interface {
Dispose() error
}
type Plugin interface {
Name() string
BindScorekeeper(*Scorekeeper)
}
type ScorekeeperTopic struct {
Plugin Plugin
Name string
DisplayName string
Description string
Fetcher ScoreValueFetcher
}
type Opener interface {
FileSystem() http.FileSystem
BasePath() string
NewOpener(path string) Opener
}
type Engine interface {
Disposable
Logger() Logger
Opener() Opener
LineParserPluginRegistry() LineParserPluginRegistry
RandSource() rand.Source
Scorekeeper() *Scorekeeper
DefaultPort() Port
Spawn(Spawnee) error
Launch(PluginInstance) error
SpawneeStatuses() ([]SpawneeStatus, error)
PluginInstances() []PluginInstance
RecurringTaskScheduler() *task.RecurringTaskScheduler
}
type InputFactory interface {
Plugin
New(engine Engine, config *ConfigElement) (Input, error)
}
type InputFactoryRegistry interface {
RegisterInputFactory(factory InputFactory) error
LookupInputFactory(name string) InputFactory
}
type OutputFactory interface {
Plugin
New(engine Engine, config *ConfigElement) (Output, error)
}
type OutputFactoryRegistry interface {
RegisterOutputFactory(factory OutputFactory) error
LookupOutputFactory(name string) OutputFactory
}
type PluginRegistry interface {
Plugins() []Plugin
}
type Scoreboard interface {
PluginInstance
}
type ScoreboardFactory interface {
Plugin
New(engine Engine, pluginRegistry PluginRegistry, config *ConfigElement) (Scoreboard, error)
}
type JournalChunk interface {
Disposable
GetReader() (io.Reader, error)
GetNextChunk() JournalChunk
TakeOwnership() bool
}
type JournalChunkListener func(JournalChunk) error
type Journal interface {
Disposable
Key() string
Write(data []byte) error
GetTailChunk() JournalChunk
AddNewChunkListener(JournalChunkListener)
AddFlushListener(JournalChunkListener)
Flush(func(JournalChunk) error) error
}
type JournalGroup interface {
Disposable
GetJournal(key string) Journal
GetJournalKeys() []string
}
type JournalGroupFactory interface {
GetJournalGroup() JournalGroup
}
type RecordPacker interface {
Pack(record FluentRecord) ([]byte, error)
}
type LineParser interface {
Feed(line string) error
}
type LineParserFactory interface {
New(receiver func(FluentRecord) error) (LineParser, error)
}
type LineParserFactoryFactory func(engine Engine, config *ConfigElement) (LineParserFactory, error)
type LineParserPlugin interface {
Name() string
OnRegistering(func(name string, factory LineParserFactoryFactory) error) error
}
type LineParserPluginRegistry interface {
RegisterLineParserPlugin(plugin LineParserPlugin) error
LookupLineParserFactoryFactory(name string) LineParserFactoryFactory
}
type Logger interface {
Critical(format string, args ...interface{})
Error(format string, args ...interface{})
Warning(format string, args ...interface{})
Notice(format string, args ...interface{})
Info(format string, args ...interface{})
Debug(format string, args ...interface{})
}