{"id":26675607,"url":"https://github.com/linkdata/bwlimit","last_synced_at":"2025-08-24T13:34:08.665Z","repository":{"id":262976079,"uuid":"888945376","full_name":"linkdata/bwlimit","owner":"linkdata","description":"Go net.Conn bandwidth limiter","archived":false,"fork":false,"pushed_at":"2025-02-05T08:23:02.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T09:28:25.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/linkdata.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":"2024-11-15T10:01:43.000Z","updated_at":"2025-02-05T08:23:05.000Z","dependencies_parsed_at":"2025-02-05T09:24:10.097Z","dependency_job_id":"97acbb48-ca9a-4ef9-8390-cd36bc720009","html_url":"https://github.com/linkdata/bwlimit","commit_stats":null,"previous_names":["linkdata/limitedconn"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Fbwlimit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Fbwlimit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Fbwlimit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdata%2Fbwlimit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkdata","download_url":"https://codeload.github.com/linkdata/bwlimit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245579675,"owners_count":20638679,"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":[],"created_at":"2025-03-26T03:18:52.384Z","updated_at":"2025-08-24T13:34:08.648Z","avatar_url":"https://github.com/linkdata.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build](https://github.com/linkdata/bwlimit/actions/workflows/go.yml/badge.svg)](https://github.com/linkdata/bwlimit/actions/workflows/go.yml)\n[![coverage](https://github.com/linkdata/bwlimit/blob/coverage/main/badge.svg)](https://htmlpreview.github.io/?https://github.com/linkdata/bwlimit/blob/coverage/main/report.html)\n[![goreport](https://goreportcard.com/badge/github.com/linkdata/bwlimit)](https://goreportcard.com/report/github.com/linkdata/bwlimit)\n[![Docs](https://godoc.org/github.com/linkdata/bwlimit?status.svg)](https://godoc.org/github.com/linkdata/bwlimit)\n\n# bwlimit\n\nGo net.Conn bandwidth limiter.\n\nOnly depends on the standard library.\n\n## Usage\n\n`go get github.com/linkdata/bwlimit`\n\n## Example\n\n```go\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"time\"\n\n\t\"github.com/linkdata/bwlimit\"\n)\n\nfunc main() {\n\tsrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"Hello world!\"))\n\t}))\n\tdefer srv.Close()\n\n\t// limit reads to 100 bytes/sec, unlimited writes\n\tlim := bwlimit.NewLimiter(100, 0)\n\tdefer lim.Stop()\n\n\t// set the default http transport DialContext\n\ttp := http.DefaultTransport.(*http.Transport)\n\ttp.DialContext = lim.Wrap(nil).DialContext\n\n\t// make a request and time it\n\tnow := time.Now()\n\tresp, err := http.Get(srv.URL)\n\telapsed := time.Since(now)\n\n\tif err == nil {\n\t\tvar body []byte\n\t\tif body, err = io.ReadAll(resp.Body); err == nil {\n\t\t\tfmt.Printf(\"%v %v %q\\n\", elapsed \u003e= time.Second, lim.Reads.Count.Load() \u003e 100, string(body))\n\t\t}\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdata%2Fbwlimit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkdata%2Fbwlimit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdata%2Fbwlimit/lists"}