{"id":18396818,"url":"https://github.com/bartventer/go-pooler","last_synced_at":"2025-04-12T15:07:17.681Z","repository":{"id":253433638,"uuid":"843458043","full_name":"bartventer/go-pooler","owner":"bartventer","description":"Generic resource pooler for managing reusable resources in Go. Handle resource acquisition, release, and health checks efficiently. Suitable for high-concurrency applications.","archived":false,"fork":false,"pushed_at":"2024-11-25T06:27:22.000Z","size":27,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-24T10:37:31.226Z","etag":null,"topics":["go","golang","pooling","resource-pool"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bartventer.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-08-16T14:59:08.000Z","updated_at":"2024-08-16T17:03:55.000Z","dependencies_parsed_at":"2024-08-16T18:04:47.686Z","dependency_job_id":"9da95009-adc3-45b8-8262-cb6dd09c0395","html_url":"https://github.com/bartventer/go-pooler","commit_stats":null,"previous_names":["bartventer/go-pooler"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgo-pooler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgo-pooler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgo-pooler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartventer%2Fgo-pooler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bartventer","download_url":"https://codeload.github.com/bartventer/go-pooler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239080898,"owners_count":19578230,"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","pooling","resource-pool"],"created_at":"2024-11-06T02:14:57.804Z","updated_at":"2025-02-16T02:32:20.925Z","avatar_url":"https://github.com/bartventer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-pooler\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/bartventer/go-pooler.svg)](https://pkg.go.dev/github.com/bartventer/go-pooler)\n[![Release](https://img.shields.io/github/release/bartventer/go-pooler.svg)](https://github.com/bartventer/go-pooler/releases/latest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bartventer/go-pooler)](https://goreportcard.com/report/github.com/bartventer/go-pooler)\n[![codecov](https://codecov.io/gh/bartventer/go-pooler/graph/badge.svg?token=EDXIGqtlaI)](https://codecov.io/gh/bartventer/go-pooler)\n[![Tests](https://github.com/bartventer/go-pooler/actions/workflows/default.yml/badge.svg)](https://github.com/bartventer/go-pooler/actions/workflows/default.yml)\n![GitHub issues](https://img.shields.io/github/issues/bartventer/go-pooler)\n[![License](https://img.shields.io/github/license/bartventer/go-pooler.svg)](LICENSE)\n\nThe `go-pooler` package provides a simple and generic resource pooler for managing reusable resources in Go. It is designed to handle resource acquisition, release, and health checks efficiently, making it suitable for high-concurrency applications.\n\n## Features\n\n - **Acquiring and Releasing Resources by Key**: Manage resources using unique keys.\n - **Configurable Maximum Number of Open Resources**: Limit the number of open resources.\n - **Periodic Health Checks**: Automatically perform health checks and resource cleanup at configurable intervals.\n - **Pool Statistics**: Gather statistics about the pool's usage, such as the number of open resources and wait times.\n\n# Installation\n\nTo install the package, use:\n\n```bash\ngo get github.com/bartventer/go-pooler\n```\n\n# Basic Usage\n\nTo create a new pool, define a resource that implements the Reusable interface and use the NewPool function:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/bartventer/go-pooler\"\n)\n\ntype Worker struct{}\ntype WorkerPool = pooler.Pool[*Worker]\n\nfunc (w *Worker) Close() error                          { return nil }\nfunc (w *Worker) PingContext(ctx context.Context) error { return nil }\n\nfunc WorkerFactory() (*Worker, error) {\n\treturn \u0026Worker{}, nil\n}\n\nfunc NewWorkerPool(ctx context.Context, opts ...pooler.Option) *WorkerPool {\n\treturn pooler.NewPool(ctx, WorkerFactory, opts...)\n}\n\nfunc main() {\n\tctx := context.Background()\n\tp := NewWorkerPool(ctx, pooler.WithMaxOpenResources(1))\n\n\t_, err := p.Acquire(ctx, \"key1\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer p.Release(\"key1\")\n\n\t// Use the worker...\n}\n```\n\n# Documentation\n\nRefer to the [GoDoc](https://pkg.go.dev/github.com/bartventer/go-pooler) for detailed documentation and examples.\n\n## License\n\nThis project is licensed under the Apache License, Version 2.0 - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartventer%2Fgo-pooler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartventer%2Fgo-pooler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartventer%2Fgo-pooler/lists"}