func healthCheckNSQ() (interface{}, error) { if err := nsq.Connect(meta.MC.NSQd[0]); err == nil { return fmt.Sprintf("%s up", meta.MC.NSQd[0]), nil } else { return nil, err } }
func main() { flag.Parse() producer.Connect(*nsqdAddr) for _ = range time.NewTicker(100 * time.Millisecond).C { fmt.Println("Ping...") for i := 0; i < *amount; i++ { body, _ := time.Now().MarshalBinary() producer.PublishAsync("latency-test", body, nil) } } }
func main() { producer.Connect(nsqdAddr) var crawlJob struct { host string } crawlJob.host = "google.com" body, _ := producer.EncJson(crawlJob) for i := 0; i < 10000; i++ { producer.PublishAsync("crawl", body, nil) // producer.PublishJsonAsync("crawl", crawlJob, nil) } }