rcrowley / goagain

Zero-downtime restarts in Go
Other
2.1k stars 144 forks source link

Drop-in replacement for net.Listen #23

Open infogulch opened 10 years ago

infogulch commented 10 years ago

Would it be possible to wrap some of the complexity of the handoff / setup code? With a similar signature as net.Listen, it should either resume the previous connection or set up a new one. This could be performed by calling goagain.Listener() and depending on whether it succeeds, either kill off the parent (or other appropriate cleanup) or return a new net.Listener by calling net.Listen(net, laddr).

Basically handling all of example/simple/simple.go#L20-44 (but just returning the listener). This would make the library a near drop-in replacement of the standard net.Listener.

It could be named goagain.Listen akin to net.Listen, goagain.ListenAgain, or maybe goagain.ReListen.

infogulch commented 10 years ago

Would you accept a patch that provides this functionality?

cenkalti commented 7 years ago

Not exactly what you are looking for but I have adapted this package for using with HTTP servers:

https://github.com/cenkalti/httpagain

See https://github.com/cenkalti/httpagain/blob/master/httpagaindemo/demo.go for usage.