{"id":13526806,"url":"https://github.com/korovkin/limiter","last_synced_at":"2025-04-01T08:30:25.604Z","repository":{"id":22548341,"uuid":"91190545","full_name":"korovkin/limiter","owner":"korovkin","description":"go lang concurrency limiter.","archived":false,"fork":false,"pushed_at":"2023-04-07T19:32:09.000Z","size":26,"stargazers_count":274,"open_issues_count":3,"forks_count":36,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-02T06:23:11.437Z","etag":null,"topics":["go","golang","goroutine","goroutine-pool"],"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/korovkin.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}},"created_at":"2017-05-13T17:15:41.000Z","updated_at":"2024-05-28T20:30:54.000Z","dependencies_parsed_at":"2024-01-13T22:21:05.442Z","dependency_job_id":null,"html_url":"https://github.com/korovkin/limiter","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/korovkin%2Flimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korovkin%2Flimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korovkin%2Flimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korovkin%2Flimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/korovkin","download_url":"https://codeload.github.com/korovkin/limiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222709936,"owners_count":17026767,"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":["go","golang","goroutine","goroutine-pool"],"created_at":"2024-08-01T06:01:35.275Z","updated_at":"2024-11-02T11:31:41.335Z","avatar_url":"https://github.com/korovkin.png","language":"Go","readme":"# go lang goroutine concurrency limiter\n\n## builds\n\n[![Build Status](https://travis-ci.org/korovkin/limiter.svg)](https://travis-ci.org/korovkin/limiter)\n\n## Example\n\nlimit the number of concurrent go routines to 10:\n\n```\n  import \"github.com/korovkin/limiter\"\n\n  ...\n\n  limit := limiter.NewConcurrencyLimiter(10)\n  defer limit.WaitAndClose()\n\n  for i := 0; i \u003c 1000; i++ {\n    limit.Execute(func() {\n      // do some work\n    })\n  }\n```\n\n## Real World Example:\n\n```\n  import \"github.com/korovkin/limiter\"\n\n  ...\n\n  limiter := limiter.NewConcurrencyLimiter(10)\n\n  httpGoogle := int(0)\n  limiter.Execute(func() {\n    resp, err := http.Get(\"https://www.google.com/\")\n    Expect(err).To(BeNil())\n    defer resp.Body.Close()\n    httpGoogle = resp.StatusCode\n  })\n\n  httpApple := int(0)\n  limiter.Execute(func() {\n    resp, err := http.Get(\"https://www.apple.com/\")\n    Expect(err).To(BeNil())\n    defer resp.Body.Close()\n    httpApple = resp.StatusCode\n  })\n\n  limiter.WaitAndClose()\n\n  log.Println(\"httpGoogle:\", httpGoogle)\n  log.Println(\"httpApple:\", httpApple)\n```\n\n## Concurrent IO with Error tracking:\n\n```\n  import \"github.com/korovkin/limiter\"\n  ...\n\ta := errors.New(\"error a\")\n\tb := errors.New(\"error b\")\n\n\tconcurrently := limiter.NewConcurrencyLimiterForIO(limiter.DefaultConcurrencyLimitIO)\n\tconcurrently.Execute(func() {\n\t\t// Do some really slow IO ...\n\t\t// keep the error:\n\t\tconcurrently.FirstErrorStore(a)\n\t})\n\tconcurrently.Execute(func() {\n\t\t// Do some really slow IO ...\n\t\t// keep the error:\n\t\tconcurrently.FirstErrorStore(b)\n\t})\n\tconcurrently.WaitAndClose()\n\n\tfirstErr := concurrently.FirstErrorGet()\n\tExpect(firstErr == a || firstErr == b).To(BeTrue())\n\n```\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorovkin%2Flimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkorovkin%2Flimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorovkin%2Flimiter/lists"}