Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nsq_to_file: require --topic or --topic-pattern #794

Merged
merged 1 commit into from
Oct 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/nsq_to_file/nsq_to_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
gzipEnabled = flag.Bool("gzip", false, "gzip output files.")
skipEmptyFiles = flag.Bool("skip-empty-files", false, "Skip writing empty files")
topicPollRate = flag.Duration("topic-refresh", time.Minute, "how frequently the topic list should be refreshed")
topicPattern = flag.String("topic-pattern", ".*", "Only log topics matching the following pattern")
topicPattern = flag.String("topic-pattern", "", "Only log topics matching the following pattern")

rotateSize = flag.Int64("rotate-size", 0, "rotate the file when it grows bigger than `rotate-size` bytes")
rotateInterval = flag.Duration("rotate-interval", 0*time.Second, "rotate the file every duration")
Expand Down Expand Up @@ -399,6 +399,9 @@ func (t *TopicDiscoverer) startTopicRouter(logger *ConsumerFileLogger) {
}

func (t *TopicDiscoverer) allowTopicName(pattern string, name string) bool {
if pattern == "" {
return true
}
match, err := regexp.MatchString(pattern, name)
if err != nil {
return false
Expand Down Expand Up @@ -526,6 +529,9 @@ func main() {
signal.Notify(discoverer.termChan, syscall.SIGINT, syscall.SIGTERM)

if len(topics) < 1 {
if len(*topicPattern) < 1 {
log.Fatal("use --topic to list at least one topic to subscribe to or specify --topic-pattern to subscribe to matching topics (use \"--topic-pattern .*\" to subscribe to all topics)")
}
if len(lookupdHTTPAddrs) < 1 {
log.Fatal("use --topic to list at least one topic to subscribe to or specify at least one --lookupd-http-address to subscribe to all its topics")
}
Expand Down