{"id":34514178,"url":"https://github.com/koykov/lbpool","last_synced_at":"2026-02-23T23:27:08.580Z","repository":{"id":48577881,"uuid":"234416600","full_name":"koykov/lbpool","owner":"koykov","description":"Pool based on leaky buffer template.","archived":false,"fork":false,"pushed_at":"2023-04-23T19:32:19.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-01T12:51:09.933Z","etag":null,"topics":["leaky-buffer","pool"],"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/koykov.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,"zenodo":null}},"created_at":"2020-01-16T21:36:14.000Z","updated_at":"2022-06-24T19:24:41.000Z","dependencies_parsed_at":"2025-08-20T15:58:14.141Z","dependency_job_id":"59679bf8-7baa-494b-b811-d9b1d5b9a9b7","html_url":"https://github.com/koykov/lbpool","commit_stats":null,"previous_names":["koykov/ltpool"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/koykov/lbpool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Flbpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Flbpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Flbpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Flbpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koykov","download_url":"https://codeload.github.com/koykov/lbpool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koykov%2Flbpool/sbom","scorecard":{"id":568758,"data":{"date":"2025-08-11","repo":{"name":"github.com/koykov/lbpool","commit":"310eac7dc6f59da615e039f29cf57b1d36992aaf"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/14 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license.md:0","Info: FSF or OSI recognized license: MIT License: license.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 15 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T15:44:15.500Z","repository_id":48577881,"created_at":"2025-08-20T15:44:15.500Z","updated_at":"2025-08-20T15:44:15.500Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27994570,"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","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["leaky-buffer","pool"],"created_at":"2025-12-24T04:18:25.732Z","updated_at":"2026-02-23T23:27:08.575Z","avatar_url":"https://github.com/koykov.png","language":"Go","readme":"# Leaky Buffer Pool\n\nAn implementation of `Pool` based on the [leaky buffer](https://golang.org/doc/effective_go.html#leaky_buffer) pattern.\nActually, this pattern is more accurately called [leaky bucket](https://en.wikipedia.org/wiki/Leaky_bucket), but in Go terminology,\nthis specific name is used.\n\nThis solution has both advantages and disadvantages in comparison to native [sync.Pool](https://golang.org/src/sync/pool.go) implementation:\nthe native solution is faster, but it has a significant drawback:\n\u003e Any item stored in the Pool may be removed automatically at any time without\nnotification. If the Pool holds the only reference when this happens, the\nitem might be deallocated.\n\u003e - https://golang.org/src/sync/pool.go\n\nIf you need to store something in the pool that cannot be automatically cleaned up by the GC, you will encounter a memory leak.\nSuch objects include, for example, [cbyte](https://github.com/koykov/cbyte) arenas, which require manual release.\n\nOutside of this feature, this pool works similarly to the native one.\n\n## API\n\nThe `Get` method of the pool is full analogue to the native pool's method and has the same signature:\n```go\nfunc Get() any\n```\n\nThe `Put` method can only accept objects that implement the `Releaser` interface:\n```go\ntype Releaser interface {\n    Release()\n}\n\nfunc Put(x Releaser) bool\n```\nIt also returns a `bool` indicating whether the object leaked past the bucket or not.\n\nThe pool requires initialization via the `New` constructor:\n```go\nfunc New(size uint, releaseFactor float64, options ...Option) Pool\n```\nwith arguments:\n* `size` - The maximum size of the pool. Once this size is reached, all newly arriving elements will leak.\n* `releaseFactor` - The proportion of incoming elements that will be forcibly leaked past the pool. This is needed for gradual renewal of elements in the pool.\n* `options` - A list of optional functions that allow setting additional pool parameters.\n\nCurrently, three optional functions are available:\n* `WithNewFn` - Sets the New function for constructing an object to return instead of a `nil` value.\n* `WithShards` - The number of pool shards, needed to reduce lock contention on the internal channel's mutex.\n* `WithSampler` - Sets the sampler ti evaluate should item stored to the pool or not. May be helpful to refresh pool.\n* `WithMetricsWriter` - Connects a component for writing metrics to the pool.\n\n## Usage\n\n```go\nimport (\n    \"github.com/koykov/lbpool\"\n    \"github.com/koykov/lbpool/metrics/victoria\"\n)\n\nconst (\n    poolSize      = 100 // max pool size\n    releaseFactor = .05 // part of items that will leak independent of leaky logic\n)\n\ntype item struct{...}\n\nfunc (item) Release() {...}\n\nvar pool = lbpool.New(poolSize, releaseFactor, lbpool.WithNewFn(func() any { return \u0026item{} }),\nlbpool.WithMetricsWriter(victoria.NewWriter(\"my_pool\")))\n\nitm := pool.Get().(*item)\n...\npool.Put(itm)\n```\n\n## Performance\n\nThe pool is implemented over Go channels and works several times slower than the native pool:\n```\nBenchmarkPool-8                 \t23870334\t        50.07 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkPoolParallel-8         \t100000000\t        11.62 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkPoolNative-8           \t100000000\t        10.59 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkPoolNativeParallel-8   \t424538383\t        2.920 ns/op\t       0 B/op\t       0 allocs/op\n```\nConsider this when choosing tools for your tasks.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoykov%2Flbpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoykov%2Flbpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoykov%2Flbpool/lists"}