fix panic when checking if es/nats event target is active (#9587)

master
poornas 5 years ago committed by GitHub
parent 94f1a1dea3
commit 2ecf5ba1de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      pkg/event/target/elasticsearch.go
  2. 2
      pkg/event/target/nsq.go

@ -103,6 +103,13 @@ func (target *ElasticsearchTarget) IsActive() (bool, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if target.client == nil {
client, err := newClient(target.args)
if err != nil {
return false, err
}
target.client = client
}
_, code, err := target.client.Ping(target.args.URL.String()).HttpHeadOnly(true).Do(ctx)
if err != nil {
if elastic.IsConnErr(err) || elastic.IsContextErr(err) || xnet.IsNetworkOrHostDown(err) {

@ -106,7 +106,7 @@ func (target *NSQTarget) HasQueueStore() bool {
// IsActive - Return true if target is up and active
func (target *NSQTarget) IsActive() (bool, error) {
if target.producer != nil {
if target.producer == nil {
producer, err := nsq.NewProducer(target.args.NSQDAddress.String(), target.config)
if err != nil {
return false, err

Loading…
Cancel
Save