FAQ
How can I use the Go http server to serve normal http requests and also
wrap a non thread-safe library ?

My starting point is the example bradfitz posted on how to run the handlers
serially:
https://groups.google.com/d/msg/golang-nuts/bTb_va88beA/0I58wwn8ekEJ

Ideally, I would also want to use the gorilla/mux library. Any ideas on how
to "handle" this ?

thanks
jose

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jesse McNelis at Oct 18, 2013 at 1:57 am

    On Fri, Oct 18, 2013 at 4:28 AM, Jose wrote:

    How can I use the Go http server to serve normal http requests and also
    wrap a non thread-safe library ?

    My starting point is the example bradfitz posted on how to run the
    handlers serially:
    https://groups.google.com/d/msg/golang-nuts/bTb_va88beA/0I58wwn8ekEJ

    Ideally, I would also want to use the gorilla/mux library. Any ideas on
    how to "handle" this ?
    If you want to wrap a non thread-safe library the best option is to have a
    single goroutine responsible for it and have other goroutines submit
    requests over a channel.
    Generally it's best for them to submit their request along with a channel
    for the reply.

    You don't need to intentionally make the http requests process serially
    because all you need is serial access to the library which communicating
    with a single goroutine will provide.


    --
    =====================
    http://jessta.id.au

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jose at Oct 20, 2013 at 8:53 am
    thanks, I realize now it's simpler to do than I initially thought when
    looking at the example.

    On Fri, Oct 18, 2013 at 3:57 AM, Jesse McNelis wrote:
    On Fri, Oct 18, 2013 at 4:28 AM, Jose wrote:

    How can I use the Go http server to serve normal http requests and also
    wrap a non thread-safe library ?

    My starting point is the example bradfitz posted on how to run the
    handlers serially:
    https://groups.google.com/d/msg/golang-nuts/bTb_va88beA/0I58wwn8ekEJ

    Ideally, I would also want to use the gorilla/mux library. Any ideas on
    how to "handle" this ?
    If you want to wrap a non thread-safe library the best option is to have a
    single goroutine responsible for it and have other goroutines submit
    requests over a channel.
    Generally it's best for them to submit their request along with a channel
    for the reply.

    You don't need to intentionally make the http requests process serially
    because all you need is serial access to the library which communicating
    with a single goroutine will provide.


    --
    =====================
    http://jessta.id.au
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 18, '13 at 1:02a
activeOct 20, '13 at 8:53a
posts3
users2
websitegolang.org

2 users in discussion

Jose: 2 posts Jesse McNelis: 1 post

People

Translate

site design / logo © 2021 Grokbase