On 2016-10-27 16:11, Nick Patavalis wrote:
I konw that, functionally, this will work. My question is: Does this
look like a "reasonable" / "idiomatic" use of contexts?  Or will it
look "alien" to the user? I'm asking since the documentation of
"context" mentions it being used for "request-scoped" stuff, and this
is not exactly the case here.

I can instead add a Stop() method to "srv" and roll-my-own stopping
logic.

Which would you choose?

It's a valid question whether Context is the concept to use for starting and stopping server instances. ... I'm not fully convinced. It seems to me it's more meaningfull for more transient things like Requests.

Anyway ... I know what I did in the similiar situation:

https://github.com/One-com/gone/blob/master/example.go

Servers are basically started by calling Serve() ... which blocks until someone, somewhere invokes Shutdown()

The whole daemon process can manage any number of objects implementing:

type Server interface {
        Serve() error // start serving and block until exit
        Shutdown()    // async req. to shutdown, must not block
}

/Peter

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