Skip to content

Commit

Permalink
Add fast_fail config to filebeat (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng authored Jul 31, 2024
1 parent e180e57 commit 96dac9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pulsar/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ type pulsarConfig struct {
BatchingMaxPublishDelay time.Duration `config:"batching_max_publish_delay"`
BatchingMaxMessages uint `config:"batching_max_messages"`
MaxCacheProducers int `config:"max_cache_producers" validate:"min=1"`

// exit immediately if the connection to pulsar fails
FastFail bool `config:"fast_fail"`
}

func defaultConfig() pulsarConfig {
Expand All @@ -83,6 +86,7 @@ func defaultConfig() pulsarConfig {
BulkMaxSize: 2048,
MaxRetries: 3,
MaxCacheProducers: 8,
FastFail: true,
}
}

Expand Down
4 changes: 4 additions & 0 deletions pulsar/producers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package pulsar

import (
"os"
"sync"

"github.com/apache/pulsar-client-go/pulsar"
Expand Down Expand Up @@ -111,6 +112,9 @@ func (p *Producers) getOrCreateProducer(topic string, client *client) (pulsar.Pr
logp.Info("created pulsar producer for topic: %s", topic)
} else {
logp.Err("creating pulsar producer{topic=%s} failed: %v", topic, err)
if client.config.FastFail {
os.Exit(1)
}
}

p.lock.Unlock()
Expand Down

0 comments on commit 96dac9c

Please sign in to comment.