{"id":29151361,"url":"https://github.com/karpeleslab/limitlistener","last_synced_at":"2025-07-01T00:09:08.911Z","repository":{"id":232738256,"uuid":"785042208","full_name":"KarpelesLab/limitlistener","owner":"KarpelesLab","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-11T06:59:06.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T13:38:06.587Z","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/KarpelesLab.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-04-11T04:28:04.000Z","updated_at":"2024-04-11T04:28:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"6d35b4d9-7fe2-4918-baa5-00c50a29828e","html_url":"https://github.com/KarpelesLab/limitlistener","commit_stats":null,"previous_names":["karpeleslab/limitlistener"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/KarpelesLab/limitlistener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Flimitlistener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Flimitlistener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Flimitlistener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Flimitlistener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KarpelesLab","download_url":"https://codeload.github.com/KarpelesLab/limitlistener/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Flimitlistener/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262870877,"owners_count":23377314,"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-07-01T00:09:04.477Z","updated_at":"2025-07-01T00:09:08.873Z","avatar_url":"https://github.com/KarpelesLab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/KarpelesLab/limitlistener?status.svg)](https://godoc.org/github.com/KarpelesLab/limitlistener)\n\n# limitlistener\n\nThis library makes it easy to limit the number of live threads for a given listener. This\ncan be useful in a number of cases to ensure not too many connections will be processed\nat the same time rather than letting go create new goroutines like there is no tomorrow.\n\nAny call to `Accept()` when the limit has been reached will wait for any of the currently\nrunning connections to close before accepting any new connection.\n\n## Usage\n\n```go\nl, err := net.Listen(\"tcp\", \":12345\")\nif err != nil {\n    // ...\n}\n\n// limit to 128 concurrent processes\nl = limitlistener.New(l, 128)\n\nfor {\n    c, err := l.Accept()\n    if err != nil {\n        return err\n    }\n\n    // safe to start a goroutine here, will be limited to 128 routines\n    go handleClient(c)\n}\n\nhandleClient(c net.Conn) {\n    defer c.Close()\n\n    // ...\n}\n```\n\nThis can be used for a `http.Server` or anything that takes a `net.Listener` and will\napply the limit as standard as possible. Multiple threads calling Accept() are also\nsupported.\n\nIf using this with `http.Server` be careful to set a `ReadTimeout` or you may end\nblocked just with idle connections.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpeleslab%2Flimitlistener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarpeleslab%2Flimitlistener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpeleslab%2Flimitlistener/lists"}