{"id":20689420,"url":"https://github.com/paulshpilsher/concurrent-go","last_synced_at":"2026-07-16T00:31:54.980Z","repository":{"id":65774669,"uuid":"597313815","full_name":"PaulShpilsher/concurrent-go","owner":"PaulShpilsher","description":"Golang: a concurrent function runner with quota on how many functions can be executing at the same time.  There are two flavors of concurrent runners are implemented. One that uses semaphore synchronization primitive and the other uses channels.","archived":false,"fork":false,"pushed_at":"2023-11-23T16:34:57.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T16:59:06.752Z","etag":null,"topics":["go","goatomic","gochannels","golang","golang-package","goroutine","goroutine-pool","semaphore"],"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/PaulShpilsher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-02-04T06:26:43.000Z","updated_at":"2024-10-02T15:48:39.000Z","dependencies_parsed_at":"2023-11-23T17:45:37.237Z","dependency_job_id":null,"html_url":"https://github.com/PaulShpilsher/concurrent-go","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.25,"last_synced_commit":"98a074bd15791b8ee3fd180b810d4e34a47c7b53"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulShpilsher%2Fconcurrent-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulShpilsher%2Fconcurrent-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulShpilsher%2Fconcurrent-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulShpilsher%2Fconcurrent-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaulShpilsher","download_url":"https://codeload.github.com/PaulShpilsher/concurrent-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242951083,"owners_count":20211572,"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","goatomic","gochannels","golang","golang-package","goroutine","goroutine-pool","semaphore"],"created_at":"2024-11-16T23:09:37.920Z","updated_at":"2025-10-25T06:39:48.072Z","avatar_url":"https://github.com/PaulShpilsher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang concurrent function (goroutine) runner with quota\n[![Go Report Card](https://goreportcard.com/badge/github.com/paulshpilsher/concurrent-go)](https://goreportcard.com/report/github.com/paulshpilsher/concurrent-go)\n\nA concurrent function runner with quota on how many functions can be executing at the same time.\n\n## Features\n\nA concurrent runner purpose is to enforce maximum number of goroutines that can execute simultaneously (quota).  When the quota is reached scheduling new function executions is blocked until some of the running functions are finished.\n\nIt also maintains an atomic counter of how many functions are executing at any point of time.\n\n## Implementation\n\nThere are two flavors of concurrent runners are implemented.  One that uses semaphore synchronization primitive and the other uses channels.\n\nBoth have common functionality described by the interface:\n\n```go\ntype Runner interface {\n   // Concurrently executes a function wrapped in a goroutine.\n   Run(task func()) error\n\n   // Waits for all running functions to complete and frees resources.\n   WaitAndClose() error\n\n   // Returns the number of currently executing functions.\n   GetNumberOfRunningTasks() int\n\n   // Returns the quota limit\n   GetQuota() int\n}\n```\n\n## Usage\n\nGet the package\n\n```bash\ngo get github.com/paulshpilsher/concurrent-go\n```\n\nIn code import runner.\n\nTo use channel-based runner:\n\n```go\nimport \"github.com/paulshpilsher/concurrent-go/concurrency/chan/runner\"\n```\n\nTo use sync-based runner:\n\n```go\nimport \"github.com/paulshpilsher/concurrent-go/concurrency/sync/runner\"\n```\n\nUse the runner\n\n```go\n theRunner := runner.New(quota)\n if err != nil {\n    panic(err)\n }\n \n for i := 0; i \u003c 1000; i++ {\n  theRunner.Run(func() {\n   // put some code to be exectuted\n  })\n }\n\n theRunner.WaitAndClose()\n```\n\n## Examples\n\nThe exapmples are in the ./examples/ directory.\n\nRunning examples using make utility:\n\n```shell\nmake run-example-channel\n```\n\nor\n\n```shell\nmake run-example-sync\n```\n\n## Testing\n\nRunning unit tests using make utility:\n\n```shell\nmake test\n```\n\nBenchmarks:\n\n```shell\nmake bench\n```\n\n## Acknowledgements\n\n- Inspiration [\"Simple Made Easy\" - Rich Hickey (2011)](https://www.youtube.com/watch?v=SxdOUGdseq4)\n- References\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulshpilsher%2Fconcurrent-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulshpilsher%2Fconcurrent-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulshpilsher%2Fconcurrent-go/lists"}