{"id":22351048,"url":"https://github.com/ewohltman/pool","last_synced_at":"2025-07-30T07:31:37.923Z","repository":{"id":57490163,"uuid":"97065841","full_name":"ewohltman/pool","owner":"ewohltman","description":"Go library that wraps http.Client to provide seamless higher-level connection pooling features","archived":false,"fork":false,"pushed_at":"2018-10-28T23:05:50.000Z","size":11,"stargazers_count":42,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-19T06:53:56.802Z","etag":null,"topics":["connection-pool","go","golang","pool","pooling"],"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/ewohltman.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}},"created_at":"2017-07-13T01:15:34.000Z","updated_at":"2024-04-08T13:59:40.000Z","dependencies_parsed_at":"2022-09-26T18:11:50.374Z","dependency_job_id":null,"html_url":"https://github.com/ewohltman/pool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewohltman%2Fpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewohltman%2Fpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewohltman%2Fpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ewohltman%2Fpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ewohltman","download_url":"https://codeload.github.com/ewohltman/pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228106545,"owners_count":17870437,"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":["connection-pool","go","golang","pool","pooling"],"created_at":"2024-12-04T12:12:26.216Z","updated_at":"2024-12-04T12:12:26.953Z","avatar_url":"https://github.com/ewohltman.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# pool - An HTTP Client with autonomous connection pooling and rate limiting\r\n[![GoDoc](https://godoc.org/github.com/ewohltman/pool?status.svg)](https://godoc.org/github.com/ewohltman/pool)\r\n[![Go Report Card](https://goreportcard.com/badge/github.com/ewohltman/pool)](https://goreportcard.com/report/github.com/ewohltman/pool)\r\n[![Build Status](https://travis-ci.org/ewohltman/pool.svg?branch=master)](https://travis-ci.org/ewohltman/pool)\r\n\r\n\u003cbr/\u003e\r\n\r\n`pool` wraps a standard `*http.Client` to add the ability to put a maximum number of connections in the pool for the client and the requests-per-second it can perform requests at.\r\n\r\nIt 'overloads' the `http.Client.Do(req *http.Request) (*http.Response, error)` method to implement the extended functionality.  By doing so, existing codebases do not need to heavily re-factor how they already do their logic to see the effect of the more finely-tuned client.\r\n\r\nFunctions that take in a `pool.Client` allow for the ability to take in either a `*pool.PClient` or an `*http.Client` (since they both implement `Do(req *http.Request) (*http.Response, error)`).  The function must operate on the argument's Do method since it will satisfy the interface for all types passed into it.  See `doPoolTest(client Client) error` in pool_test.go for an example.\r\n\r\n## Installation\r\n\r\n- - -\r\n\r\n`go get -u github.com/ewohltman/pool`\r\n\r\n## Usage\r\n\r\n- - -\r\n\r\n```go\r\n// Some other examples are in pool_test.go\r\n\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"io/ioutil\"\r\n\t\"net/http\"\r\n\t\"net/url\"\r\n\t\"os\"\r\n\r\n\t\"github.com/ewohltman/pool\"\r\n)\r\n\r\nfunc main() {\r\n    standardLibClient := \u0026http.Client{}\r\n    \r\n    pooledClient := pool.NewPClient(standardLibClient, 25, 200)\r\n    \r\n    urlString := \"https://yourFavoriteWebsite.com/\"\r\n    \r\n    reqURL, err := url.Parse(urlString)\r\n    if err != nil {\r\n        fmt.Printf(\"[ERROR] Unable to parse: %s\", urlString)\r\n        os.Exit(1)\r\n    }\r\n    \r\n    resp, err := pooledClient.Do(\u0026http.Request{URL: reqURL})\r\n    if err != nil {\r\n        fmt.Printf(\"[ERROR] Unable to perform request: %s\", err)\r\n        os.Exit(2)\r\n    }\r\n    defer resp.Body.Close()\r\n    \r\n    _, err = ioutil.ReadAll(resp.Body)\r\n    if err != nil {\r\n        fmt.Printf(\"[ERROR] Unable to read response body: %s\", err)\r\n        os.Exit(3)\r\n    }\r\n}\r\n\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fewohltman%2Fpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fewohltman%2Fpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fewohltman%2Fpool/lists"}