fatih / Pool
Licence: mit
Connection pool for Go's net.Conn interface
Stars: ✭ 1,174
Labels
Projects that are alternatives of or similar to Pool
Ants
🐜🐜🐜 ants is a high-performance and low-cost goroutine pool in Go, inspired by fasthttp./ ants 是一个高性能且低损耗的 goroutine 池。
Stars: ✭ 7,180 (+511.58%)
Mutual labels: pool
Errand Boy
A memory-conscious alternative to os.fork() and subprocess.Popen().
Stars: ✭ 34 (-97.1%)
Mutual labels: pool
Gowp
golang worker pool , Concurrency limiting goroutine pool
Stars: ✭ 259 (-77.94%)
Mutual labels: pool
Groupco
PHP的服务化框架。适用于Api、Http Server、Rpc Server;帮助原生PHP项目转向微服务化。出色的性能与支持高并发的协程相结合
Stars: ✭ 473 (-59.71%)
Mutual labels: pool
Honeydew
Job Queue for Elixir. Clustered or Local. Straight BEAM. Optional Ecto. 💪🍈
Stars: ✭ 670 (-42.93%)
Mutual labels: pool
Mojito
An easy-to-use Elixir HTTP client, built on the low-level Mint library.
Stars: ✭ 333 (-71.64%)
Mutual labels: pool
Cardano Node Docker
Docker container for setting up and running a Cardano Stake Pool
Stars: ✭ 68 (-94.21%)
Mutual labels: pool
Archived project. No maintenance.
This project is not maintained anymore and is archived. Feel free to fork and use make your own changes if needed.
Thanks all for their work on this project.
Pool
Pool is a thread safe connection pool for net.Conn interface. It can be used to manage and reuse connections.
Install and Usage
Install the package with:
go get github.com/fatih/pool
Please vendor the package with one of the releases: https://github.com/fatih/pool/releases.
master
branch is development branch and will contain always the latest changes.
Example
// create a factory() to be used with channel based pool
factory := func() (net.Conn, error) { return net.Dial("tcp", "127.0.0.1:4000") }
// create a new channel based pool with an initial capacity of 5 and maximum
// capacity of 30. The factory will create 5 initial connections and put it
// into the pool.
p, err := pool.NewChannelPool(5, 30, factory)
// now you can get a connection from the pool, if there is no connection
// available it will create a new one via the factory function.
conn, err := p.Get()
// do something with conn and put it back to the pool by closing the connection
// (this doesn't close the underlying connection instead it's putting it back
// to the pool).
conn.Close()
// close the underlying connection instead of returning it to pool
// it is useful when acceptor has already closed connection and conn.Write() returns error
if pc, ok := conn.(*pool.PoolConn); ok {
pc.MarkUnusable()
pc.Close()
}
// close pool any time you want, this closes all the connections inside a pool
p.Close()
// currently available connections in the pool
current := p.Len()
Credits
License
The MIT License (MIT) - see LICENSE for more details
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].