{"id":15679776,"url":"https://github.com/tomwright/gopool","last_synced_at":"2025-05-07T10:42:12.566Z","repository":{"id":87426116,"uuid":"131187189","full_name":"TomWright/gopool","owner":"TomWright","description":"Easy to use worker pool with dynamic pool sizing.","archived":false,"fork":false,"pushed_at":"2018-08-07T23:36:31.000Z","size":53,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T09:11:12.541Z","etag":null,"topics":["concurrency","concurrency-library","concurrency-management","go","go-routine","golang","pool","pooling","process-pool","processing","worker","worker-management","worker-pool","worker-processes","workers"],"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/TomWright.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},"funding":{"github":"TomWright","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.buymeacoffee.com/TomWright"]}},"created_at":"2018-04-26T17:08:51.000Z","updated_at":"2024-09-01T17:28:07.000Z","dependencies_parsed_at":"2024-02-03T18:04:00.318Z","dependency_job_id":"8721c3d9-4740-49ae-92e2-5b0ddb80199c","html_url":"https://github.com/TomWright/gopool","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Fgopool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Fgopool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Fgopool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Fgopool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomWright","download_url":"https://codeload.github.com/TomWright/gopool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252862020,"owners_count":21815779,"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":["concurrency","concurrency-library","concurrency-management","go","go-routine","golang","pool","pooling","process-pool","processing","worker","worker-management","worker-pool","worker-processes","workers"],"created_at":"2024-10-03T16:36:08.864Z","updated_at":"2025-05-07T10:42:12.546Z","avatar_url":"https://github.com/TomWright.png","language":"Go","readme":"# gopool\n\n[![Build Status](https://travis-ci.org/TomWright/gopool.svg?branch=master)](https://travis-ci.org/TomWright/gopool)\n[![codecov](https://codecov.io/gh/TomWright/gopool/branch/master/graph/badge.svg)](https://codecov.io/gh/TomWright/gopool)\n[![Documentation](https://godoc.org/github.com/TomWright/gopool?status.svg)](https://godoc.org/github.com/TomWright/gopool)\n\nGo Pool makes it easy to set up and manage pools of background workers.\nNot only can they be started and stopped, but they can also be dynamically sized ensuring you have the optimal amount of workers running for your situation.\n\n## Pool Types\n\n### Long running, always alive workers\n\nTo start a pool of long running workers who's size will be managed by gopool, you should use the [Pool.Start](https://godoc.org/github.com/TomWright/gopool#Pool.Start) func.\n\nA good use case for this is when you have a message queue that jobs get published to.\nThen lets assume you want to always have at least 1 worker consuming jobs from the queue, but you also want to scale the number of consumers according to the current lag.\n\nTo do this, just pass in a [WorkerCountFunc](https://godoc.org/github.com/TomWright/gopool#WorkerCountFunc) that returns the number of workers you would want to run at any point in time, and pass in a [SleepTimeFunc](https://godoc.org/github.com/TomWright/gopool#SleepTimeFunc) to customise how often gopool should modify the number of running workers.\n\nE.g. Your [WorkerCountFunc](https://godoc.org/github.com/TomWright/gopool#WorkerCountFunc) could return the `{number of unread items in the queue} / 100`, and the [SleepTimeFunc](https://godoc.org/github.com/TomWright/gopool#SleepTimeFunc) could return `time.Second * 120`.\nThis would mean that every 2 minutes gopool would resize the pool and ensure that `X / 100` workers are running, where `X` is the number of unread items in the queue.\n\n### Temporary workers, which will die once their designated work has been finished\n\nTo start a pool of temporary workers who will die when their work input channel is closed, you should use the [Pool.StartOnce](https://godoc.org/github.com/TomWright/gopool#Pool.StartOnce) func.\n\nTo wait for the pool to finish it's work you can use the [Pool.Done](https://godoc.org/github.com/TomWright/gopool#Pool.Done) func, as the channel it returns is closed when the pool's work is done.\n\n## Installation\n\n```\ngo get -u github.com/tomwright/gopool\n```\n\n## Documentation\n\nDocumentation can be found at [https://godoc.org/github.com/tomwright/gopool](https://godoc.org/github.com/tomwright/gopool).","funding_links":["https://github.com/sponsors/TomWright","https://www.buymeacoffee.com/TomWright"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomwright%2Fgopool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomwright%2Fgopool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomwright%2Fgopool/lists"}