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_tail: safety #190

Merged
merged 1 commit into from
May 21, 2013
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
14 changes: 11 additions & 3 deletions examples/nsq_tail/nsq_tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import (
"github.com/bitly/nsq/nsq"
"github.com/bitly/nsq/util"
"log"
"math/rand"
"os"
"os/signal"
"strings"
"syscall"
"time"
)

var (
showVersion = flag.Bool("version", false, "print version string")
topic = flag.String("topic", "", "nsq topic")
channel = flag.String("channel", "nsq_tail#ephemeral", "nsq channel")
channel = flag.String("channel", "", "nsq channel")
maxInFlight = flag.Int("max-in-flight", 200, "max number of messages to allow in flight")
nsqdTCPAddrs = util.StringArray{}
lookupdHTTPAddrs = util.StringArray{}
Expand Down Expand Up @@ -47,8 +50,13 @@ func main() {
return
}

if *topic == "" || *channel == "" {
log.Fatalf("--topic and --channel are required")
if *channel == "" {
rand.Seed(time.Now().UnixNano())
*channel = fmt.Sprintf("tail%06d#ephemeral", rand.Int()%999999)
}

if *topic == "" {
log.Fatalf("--topic is required")
}

if *maxInFlight < 0 {
Expand Down