Open infogulch opened 10 years ago
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.
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 callinggoagain.Listener()
and depending on whether it succeeds, either kill off the parent (or other appropriate cleanup) or return a newnet.Listener
by callingnet.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 tonet.Listen
,goagain.ListenAgain
, or maybegoagain.ReListen
.