Use new sink instances to allow multiple of same sink type

This commit is contained in:
Thomas Roehl
2022-02-22 16:15:25 +01:00
parent 9cfbe10247
commit 18a226183c
9 changed files with 65 additions and 26 deletions

View File

@@ -19,8 +19,8 @@ type StdoutSink struct {
}
}
func (s *StdoutSink) Init(config json.RawMessage) error {
s.name = "StdoutSink"
func (s *StdoutSink) Init(name string, config json.RawMessage) error {
s.name = fmt.Sprintf("StdoutSink(%s)", name)
if len(config) > 0 {
err := json.Unmarshal(config, &s.config)
if err != nil {
@@ -65,3 +65,9 @@ func (s *StdoutSink) Close() {
s.output.Close()
}
}
func NewStdoutSink(name string, config json.RawMessage) (Sink, error) {
s := new(StdoutSink)
s.Init(name, config)
return s, nil
}