Drop-in replacement for net.Listen
infogulch opened this issue · comments
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
.
Would you accept a patch that provides this functionality?
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.