Skip to content

Instantly share code, notes, and snippets.

@mreiferson
Forked from rtecco/gist:9945119
Last active August 29, 2015 13:58
Show Gist options
  • Save mreiferson/9945305 to your computer and use it in GitHub Desktop.
Save mreiferson/9945305 to your computer and use it in GitHub Desktop.
var exitSelectCases []reflect.SelectCase
for i := 0; i < readersCount; i++ {
r, err := nsq.NewReader(topic, channel)
if err != nil {
log.Fatalln("nsq.NewReader:", err)
}
r.SetMaxInFlight(2500)
for j := 0; j < workersPerReader; j++ {
r.AddHandler(w)
}
go func(rdr *nsq.Reader, lookupd []string) {
for _, host := range lookupd {
err := rdr.ConnectToLookupd(host)
if err != nil {
log.Fatalf("ConnectToLookupd @ %s: %s\n", host, err)
}
}
}(r, hosts)
fmt.Println("added reader", i)
readers[i] = r
exitSelectCases = append(exitSelectCases, reflect.SelectCase{Dir: SelectRecv, Chan: reflect.ValueOf(r.ExitChan)})
}
reflect.Select(exitSelectCases)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment