Created
January 1, 2021 08:49
-
-
Save Happytreat/474bc41b99885c09c9e75057e4518da2 to your computer and use it in GitHub Desktop.
Reusable Errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// condRelease releases this connection if the error pointed to by err | |
// is nil (not an error) or is predefined Reusable error | |
// The purpose is to not recycle TCP connections that are bad. | |
func (cn *conn) ConnRelease(err *error) { | |
if *err == nil || resumableError(*err) { | |
cn.release() | |
} else { | |
cn.nc.Close() | |
} | |
} | |
func resumableError(err error) bool { | |
switch err { | |
case ReusableError: | |
return true | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment