Skip to content

Instantly share code, notes, and snippets.

@Happytreat
Last active January 1, 2021 07:39
Show Gist options
  • Save Happytreat/64f7c3c4a1e3457bf9345fa657f55eb3 to your computer and use it in GitHub Desktop.
Save Happytreat/64f7c3c4a1e3457bf9345fa657f55eb3 to your computer and use it in GitHub Desktop.
Connection Pool Interface
type ConnectionPool interface {
// This gets an active connection from the connection pool if exists,
// else create a new connection.
Get() (net.Conn, error)
// This releases an active connection back to the connection pool.
Release(conn net.Conn) error
// This discards an active connection from the connection pool and
// closes the connection.
Discard(conn net.Conn) error
// Enter the connection pool into a state of inactive. All active
// connections in the pool will be closed. In the inactive state,
// the pool will no longer return connections when Get() is called
// and Release(conn) will close the conn instead.
EnterInactiveState()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment