All Projects β†’ silenceper β†’ Pool

silenceper / Pool

Licence: mit
🚌 A golang general network connection poolction pool

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Pool

Worker pool
Erlang worker pool
Stars: ✭ 239 (-59.35%)
Mutual labels:  pool, hacktoberfest
Ffsend
πŸ“¬ Easily and securely share files from the command line. A fully featured Firefox Send client.
Stars: ✭ 5,448 (+826.53%)
Mutual labels:  hacktoberfest
Imgcat
It's like cat, but for images.
Stars: ✭ 577 (-1.87%)
Mutual labels:  hacktoberfest
05ab1e
A concise stack-based golfing language
Stars: ✭ 583 (-0.85%)
Mutual labels:  hacktoberfest
Laravel Telescope Toolbar
A toolbar for Laravel Telescope, based on the Symfony Web Profiler.
Stars: ✭ 578 (-1.7%)
Mutual labels:  hacktoberfest
Vue Nodegui
Build performant, native and cross-platform desktop applications with native Vue + powerful CSS like styling.πŸš€
Stars: ✭ 575 (-2.21%)
Mutual labels:  hacktoberfest
Telegram History Dump
Backup Telegram chat logs using telegram-cli
Stars: ✭ 574 (-2.38%)
Mutual labels:  hacktoberfest
Learn Graphql
Real world GraphQL tutorials for frontend developers with deadlines!
Stars: ✭ 586 (-0.34%)
Mutual labels:  hacktoberfest
Imagemagick
πŸ§™β€β™‚οΈ ImageMagick 7
Stars: ✭ 6,400 (+988.44%)
Mutual labels:  hacktoberfest
Pythainlp
Thai Natural Language Processing in Python.
Stars: ✭ 582 (-1.02%)
Mutual labels:  hacktoberfest
Font awesome flutter
The Font Awesome Icon pack available as Flutter Icons
Stars: ✭ 580 (-1.36%)
Mutual labels:  hacktoberfest
Sunpy
SunPy - Python for Solar Physics
Stars: ✭ 577 (-1.87%)
Mutual labels:  hacktoberfest
Web
Guides, tools and libraries for modern web development.
Stars: ✭ 579 (-1.53%)
Mutual labels:  hacktoberfest
Algorithms
A repository of different Algorithms and Data Structures implemented in many programming languages.
Stars: ✭ 578 (-1.7%)
Mutual labels:  hacktoberfest
Java Sdk
πŸ₯‡ Java SDK to use the IBM Watson services.
Stars: ✭ 587 (-0.17%)
Mutual labels:  hacktoberfest
Sentinelsat
Search and download Copernicus Sentinel satellite images
Stars: ✭ 576 (-2.04%)
Mutual labels:  hacktoberfest
Angular Auth Oidc Client
npm package for OpenID Connect, OAuth Code Flow with PKCE, Refresh tokens, Implicit Flow
Stars: ✭ 577 (-1.87%)
Mutual labels:  hacktoberfest
Pyproj
Python interface to PROJ (cartographic projections and coordinate transformations library)
Stars: ✭ 582 (-1.02%)
Mutual labels:  hacktoberfest
Cardview
CardsView | CarouselView | CoverflowView | CubeView for Xamarin.Forms
Stars: ✭ 587 (-0.17%)
Mutual labels:  hacktoberfest
Dataverse
Open source research data repository software
Stars: ✭ 586 (-0.34%)
Mutual labels:  hacktoberfest

pool

PkgGoDev Go Report Card

δΈ­ζ–‡ζ–‡ζ‘£

A golang universal network connection pool.

Feature:

  • More versatile, The connection type in the connection pool is interface{}, making it more versatile
  • More configurable, The connection supports setting the maximum idle time, the timeout connection will be closed and discarded, which can avoid the problem of automatic connection failure when idle
  • Support user setting ping method, used to check the connectivity of connection, invalid connection will be discarded
  • Support connection waiting, When the connection pool is full, support for connection waiting (like the go db connection pool)

Basic Usage:


//factory Specify the method to create the connection
factory := func() (interface{}, error) { return net.Dial("tcp", "127.0.0.1:4000") }

//close Specify the method to close the connection
close := func(v interface{}) error { return v.(net.Conn).Close() }

//ping Specify the method to detect whether the connection is invalid
//ping := func(v interface{}) error { return nil }

//Create a connection pool: Initialize the number of connections to 5, the maximum idle connection is 20, and the maximum concurrent connection is 30
poolConfig := &pool.Config{
	InitialCap: 5,
	MaxIdle:   20,
	MaxCap:     30,
	Factory:    factory,
	Close:      close,
	//Ping:       ping,
	//The maximum idle time of the connection, the connection exceeding this time will be closed, which can avoid the problem of automatic failure when connecting to EOF when idle
	IdleTimeout: 15 * time.Second,
}
p, err := pool.NewChannelPool(poolConfig)
if err != nil {
	fmt.Println("err=", err)
}

//Get a connection from the connection pool
v, err := p.Get()

//do something
//conn=v.(net.Conn)

//Put the connection back into the connection pool, when the connection is no longer in use
p.Put(v)

//Release all connections in the connection pool, when resources need to be destroyed
p.Release()

//View the number of connections in the current connection pool
current := p.Len()


Remarks:

The connection pool implementation refers to pool https://github.com/fatih/pool , thanks.

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].