You should not need to wait for more than a single response if any of the
responses will do the job. I've done this querying several distributed DBs
for an answer, and just taking the one that comes back fastest.

On Tue, Oct 25, 2016 at 2:53 AM, <dkxu...@gmail.com> wrote:

> in my case, i have serval child routine for query for dns record, but i
> just need a answer
>
> code looks like:
>
>     recvChan := make(chan *dnsRecord, 1)
>
>
>     defer close(recvChan)
>
>
>
>
>     for _, server := range DnsServers {
>
>
>         go doResolve(server, req, recvChan)   // query ip address
>
>
>     }
>
>
>
>
>     select {
>
>
>     case r := <-recvChan:   // receive address
>
>
>         responseRecord(w, req, r)  // response to client
>
>
>     case <-time.After(2 * time.Second):  // timeout
>
>
>         break
>
>
>     }
>
>     return
>
>
> do i need to wait all child routine exit before return
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to