mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-08-14 22:53:01 +02:00
Use new sink instances to allow multiple of same sink type
This commit is contained in:
@@ -57,8 +57,8 @@ func (s *InfluxSink) connect() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *InfluxSink) Init(config json.RawMessage) error {
|
||||
s.name = "InfluxSink"
|
||||
func (s *InfluxSink) Init(name string, config json.RawMessage) error {
|
||||
s.name = fmt.Sprintf("InfluxSink(%s)", name)
|
||||
if len(config) > 0 {
|
||||
err := json.Unmarshal(config, &s.config)
|
||||
if err != nil {
|
||||
@@ -94,3 +94,9 @@ func (s *InfluxSink) Close() {
|
||||
cclog.ComponentDebug(s.name, "Closing InfluxDB connection")
|
||||
s.client.Close()
|
||||
}
|
||||
|
||||
func NewInfluxSink(name string, config json.RawMessage) (Sink, error) {
|
||||
s := new(InfluxSink)
|
||||
s.Init(name, config)
|
||||
return s, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user