Hi gophers,

I'm designing a service exposed through a http server which uses a pool of
workers to process requests. At the moment my handlerFunc look similar to
this:

func aHandler(w http.ResponseWriter, r *http.Request) {
        var wg sync.WaitGroup
        wg.Add(1)
        reqQueue <- &RequestParams{&wg, r, w}
        wg.Wait()
}

When a worker is done, it writes on the w and calls wg.Done(). This
approach works fine but I'm not sure if passing the WaitGroup around is the
best approach. Has anyone encountered a similar situation or can suggest
alternative approaches? Could the new context package and its Done()
channel be of any help in this case?

Thank you very much for your help,
Pablo

-- 
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