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

@@ -38,9 +38,9 @@ type HttpSink struct {
flushDelay time.Duration
}
func (s *HttpSink) Init(config json.RawMessage) error {
func (s *HttpSink) Init(name string, config json.RawMessage) error {
// Set default values
s.name = "HttpSink"
s.name = fmt.Sprintf("HttpSink(%s)", name)
s.config.MaxIdleConns = 10
s.config.IdleConnTimeout = "5s"
s.config.Timeout = "5s"
@@ -169,3 +169,9 @@ func (s *HttpSink) Close() {
}
s.client.CloseIdleConnections()
}
func NewHttpSink(name string, config json.RawMessage) (Sink, error) {
s := new(HttpSink)
s.Init(name, config)
return s, nil
}