-
Notifications
You must be signed in to change notification settings - Fork 1
/
output.go
48 lines (39 loc) · 974 Bytes
/
output.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
package gopl
import (
"github.com/rs/zerolog/log"
)
//
// Author: 陈永佳 [email protected], [email protected]
// 消息输出接口
//
type Output interface {
VirtualSlot
// 处理消息
Output(pack *DataFrame)
}
type outputRunner struct {
output Output
matcher Matcher
config *ComponentConfig
configKey string
}
func newOutputRunner(output Output, matcher Matcher, config *ComponentConfig, configKey string) *outputRunner {
return &outputRunner{
output: output,
matcher: matcher,
config: config,
configKey: configKey,
}
}
func (slf *outputRunner) init() {
pluginName := slf.configKey
slf.output.SetName(pluginName)
log.Info().Msgf("Init Output: <%s>, matcher: <%T>", pluginName, slf.matcher)
go slf.output.Init(slf.config.InitArgs)
}
func (slf *outputRunner) runOutput(pack *DataFrame) {
slf.output.Output(pack)
}
func (slf *outputRunner) checkAccept(pack *DataFrame) bool {
return slf.matcher.Match(pack)
}