Add support for NSQLookupd to nsq_consumer (#3215)
This commit is contained in:
committed by
Daniel Nelson
parent
4ccef6f99e
commit
77c7b6bee5
@@ -6,12 +6,14 @@ import (
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
"github.com/influxdata/telegraf/plugins/parsers"
|
||||
"github.com/nsqio/go-nsq"
|
||||
nsq "github.com/nsqio/go-nsq"
|
||||
)
|
||||
|
||||
//NSQConsumer represents the configuration of the plugin
|
||||
type NSQConsumer struct {
|
||||
Server string
|
||||
Nsqd []string
|
||||
Nsqlookupd []string
|
||||
Topic string
|
||||
Channel string
|
||||
MaxInFlight int
|
||||
@@ -21,8 +23,12 @@ type NSQConsumer struct {
|
||||
}
|
||||
|
||||
var sampleConfig = `
|
||||
## An string representing the NSQD TCP Endpoint
|
||||
server = "localhost:4150"
|
||||
## Server option still works but is deprecated, we just prepend it to the nsqd array.
|
||||
# server = "localhost:4150"
|
||||
## An array representing the NSQD TCP HTTP Endpoints
|
||||
nsqd = ["localhost:4150"]
|
||||
## An array representing the NSQLookupd HTTP Endpoints
|
||||
nsqlookupd = ["localhost:4161"]
|
||||
topic = "telegraf"
|
||||
channel = "consumer"
|
||||
max_in_flight = 100
|
||||
@@ -71,7 +77,11 @@ func (n *NSQConsumer) Start(acc telegraf.Accumulator) error {
|
||||
message.Finish()
|
||||
return nil
|
||||
}), n.MaxInFlight)
|
||||
n.consumer.ConnectToNSQD(n.Server)
|
||||
|
||||
if len(n.Nsqlookupd) > 0 {
|
||||
n.consumer.ConnectToNSQLookupds(n.Nsqlookupd)
|
||||
}
|
||||
n.consumer.ConnectToNSQDs(append(n.Nsqd, n.Server))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user