{"id":13817104,"url":"https://github.com/silenceper/pool","last_synced_at":"2025-05-15T11:08:52.693Z","repository":{"id":41403800,"uuid":"73711220","full_name":"silenceper/pool","owner":"silenceper","description":"🚌 A golang general network connection poolction pool","archived":false,"fork":false,"pushed_at":"2023-08-15T03:15:40.000Z","size":40,"stargazers_count":846,"open_issues_count":11,"forks_count":214,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-14T19:58:56.428Z","etag":null,"topics":["golang","hacktoberfest","pool"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silenceper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://silenceper.com/img/wechat-pay.jpeg"}},"created_at":"2016-11-14T14:13:53.000Z","updated_at":"2025-04-11T10:03:10.000Z","dependencies_parsed_at":"2024-01-16T23:26:51.721Z","dependency_job_id":"b91df8d7-6f8f-4247-b01d-0d5723e47003","html_url":"https://github.com/silenceper/pool","commit_stats":{"total_commits":35,"total_committers":9,"mean_commits":3.888888888888889,"dds":0.6857142857142857,"last_synced_commit":"58e025e48bf97061c9f2638564fd6857092caeb4"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silenceper%2Fpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silenceper%2Fpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silenceper%2Fpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silenceper%2Fpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silenceper","download_url":"https://codeload.github.com/silenceper/pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328385,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","hacktoberfest","pool"],"created_at":"2024-08-04T06:00:33.726Z","updated_at":"2025-05-15T11:08:52.676Z","avatar_url":"https://github.com/silenceper.png","language":"Go","funding_links":["https://silenceper.com/img/wechat-pay.jpeg"],"categories":["Misc","Go"],"sub_categories":[],"readme":"# pool\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/silenceper/pool)](https://pkg.go.dev/github.com/silenceper/pool)\n[![Go Report Card](https://goreportcard.com/badge/github.com/silenceper/pool)](https://goreportcard.com/report/github.com/silenceper/pool)\n\n\n[中文文档](./README_ZH_CN.md)\n\nA golang universal network connection pool.\n\n## Feature：\n\n- More versatile, The connection type in the connection pool is `interface{}`, making it more versatile\n- 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\n- Support user setting `ping` method, used to check the connectivity of connection, invalid connection will be discarded\n- Support connection waiting, When the connection pool is full, support for connection waiting (like the go db connection pool)\n\n## Basic Usage:\n\n```go\n\n//factory Specify the method to create the connection\nfactory := func() (interface{}, error) { return net.Dial(\"tcp\", \"127.0.0.1:4000\") }\n\n//close Specify the method to close the connection\nclose := func(v interface{}) error { return v.(net.Conn).Close() }\n\n//ping Specify the method to detect whether the connection is invalid\n//ping := func(v interface{}) error { return nil }\n\n//Create a connection pool: Initialize the number of connections to 5, the maximum idle connection is 20, and the maximum concurrent connection is 30\npoolConfig := \u0026pool.Config{\n\tInitialCap: 5,\n\tMaxIdle:   20,\n\tMaxCap:     30,\n\tFactory:    factory,\n\tClose:      close,\n\t//Ping:       ping,\n\t//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\n\tIdleTimeout: 15 * time.Second,\n}\np, err := pool.NewChannelPool(poolConfig)\nif err != nil {\n\tfmt.Println(\"err=\", err)\n}\n\n//Get a connection from the connection pool\nv, err := p.Get()\n\n//do something\n//conn=v.(net.Conn)\n\n//Put the connection back into the connection pool, when the connection is no longer in use\np.Put(v)\n\n//Release all connections in the connection pool, when resources need to be destroyed\np.Release()\n\n//View the number of connections in the current connection pool\ncurrent := p.Len()\n\n\n```\n\n\n#### Remarks:\nThe connection pool implementation refers to pool [https://github.com/fatih/pool](https://github.com/fatih/pool) , thanks.\n\n\n## License\n\nThe MIT License (MIT) - see LICENSE for more details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilenceper%2Fpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilenceper%2Fpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilenceper%2Fpool/lists"}