Skip to content

Instantly share code, notes, and snippets.

@brianmario
Last active August 29, 2015 13:58
Show Gist options
  • Save brianmario/9940647 to your computer and use it in GitHub Desktop.
Save brianmario/9940647 to your computer and use it in GitHub Desktop.
Connection pool example for Go
type ConnectionPool chan *Conn
func (p *ConnectionPool) Checkout() *Conn {
<- p
}
func (p *ConnectionPool) Checkin(conn *Conn) {
p <- conn
}
// ...............
pool := make(ConnectionPool, 20)
conn := pool.Checkout()
defer pool.Checkin(conn)
// do some shit with conn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment