{"id":21981822,"url":"https://github.com/liou2021/tcp-pool","last_synced_at":"2025-03-23T01:19:11.009Z","repository":{"id":153234040,"uuid":"628588141","full_name":"LIOU2021/tcp-pool","owner":"LIOU2021","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-19T03:21:50.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T04:29:14.140Z","etag":null,"topics":["golang","pool","ring-buffer","tcp-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/LIOU2021.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-16T12:27:40.000Z","updated_at":"2023-09-19T03:29:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ce964c7-c11d-4659-8b32-ef1323c60463","html_url":"https://github.com/LIOU2021/tcp-pool","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIOU2021%2Ftcp-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIOU2021%2Ftcp-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIOU2021%2Ftcp-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIOU2021%2Ftcp-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LIOU2021","download_url":"https://codeload.github.com/LIOU2021/tcp-pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245041216,"owners_count":20551381,"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","pool","ring-buffer","tcp-pool"],"created_at":"2024-11-29T17:19:52.206Z","updated_at":"2025-03-23T01:19:11.000Z","avatar_url":"https://github.com/LIOU2021.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# introduction\n- 底层采用带有头尾指标的ring buffer循环利用记忆体\n# ref\n- [golang 环形队列](https://juejin.cn/s/golang%20%E7%8E%AF%E5%BD%A2%E9%98%9F%E5%88%97)\n- [go语言数据结构 环形队列](https://cloud.tencent.com/developer/article/1165585)\n# tcp connect pool\n\n# example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net\"\n\t\"time\"\n\n\t\"github.com/LIOU2021/tcp-pool/pool\"\n)\n\nfunc main() {\n\taddress := \"127.0.0.1:8000\"\n\n\tpool := \u0026pool.ConnPool{\n\t\tDial: func() (net.Conn, error) {\n\t\t\treturn net.Dial(\"tcp\", address)\n\t\t},\n\t\tMaxIdle:  10,\n\t\tMinIdle:  2,\n\t\tIdleTime: 10 * time.Second,\n\t}\n\n\tpool.CreatePool()\n\n\tconn, err := pool.Get()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tconn.Write([]byte(fmt.Sprintf(\"echo %s\", \"hello world\")))\n\tbuf := make([]byte, 4096)\n\n\tcnt, err := conn.Read(buf)\n\tif err != nil {\n\t\tfmt.Printf(\"Fail to read from server: %s\\n\", err)\n\t}\n\tfmt.Println(string(buf[0:cnt]))\n\n\tpool.Put(conn)\n\n\tpool.Release()\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliou2021%2Ftcp-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliou2021%2Ftcp-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliou2021%2Ftcp-pool/lists"}