{"id":16834626,"url":"https://github.com/gobwas/hashring","last_synced_at":"2025-10-10T18:06:00.686Z","repository":{"id":51650961,"uuid":"376342925","full_name":"gobwas/hashring","owner":"gobwas","description":"Consistent hashing hashring implementation.","archived":false,"fork":false,"pushed_at":"2023-12-15T07:22:04.000Z","size":185,"stargazers_count":34,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T03:41:21.229Z","etag":null,"topics":["consistent-hashing","go","golang","hashring"],"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/gobwas.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":"2021-06-12T17:00:45.000Z","updated_at":"2024-08-08T16:38:18.000Z","dependencies_parsed_at":"2023-12-15T08:27:05.390Z","dependency_job_id":"edac295a-ec0d-4ce7-9bad-036c5d9ff572","html_url":"https://github.com/gobwas/hashring","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/gobwas/hashring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhashring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhashring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhashring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhashring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gobwas","download_url":"https://codeload.github.com/gobwas/hashring/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhashring/sbom","scorecard":{"id":433081,"data":{"date":"2025-08-11","repo":{"name":"github.com/gobwas/hashring","commit":"38066417e77e00d922754796f5e9178fab42493f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 2/23 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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/gobwas/hashring/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/gobwas/hashring/main.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"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":"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":"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:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"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":"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 8 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-19T03:50:40.612Z","repository_id":51650961,"created_at":"2025-08-19T03:50:40.612Z","updated_at":"2025-08-19T03:50:40.612Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004906,"owners_count":26083802,"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-10-10T02:00:06.843Z","response_time":62,"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":["consistent-hashing","go","golang","hashring"],"created_at":"2024-10-13T12:07:10.068Z","updated_at":"2025-10-10T18:06:00.656Z","avatar_url":"https://github.com/gobwas.png","language":"Go","readme":"# hashring\n\n[![GoDoc][godoc-image]][godoc-url]\n[![CI][ci-badge]][ci-url]\n\n\u003e Consistent hashing hashring implementation.\n\n# Overview\n\nThis is an implementation of the consistent hashing hashring data structure.\n\nIn general, consistent hashing is all about mapping objects from a very big set\nof values (e.g., request id) to objects from a quite small set (e.g., server\naddress). The word \"consistent\" means that it can produce consistent mapping on\ndifferent machines or processes without additional state exchange and\ncommunication.\n\nFor more theory about the subject please see this [great\ndocument][stanford-doc].\n\nFor more info about the package please read the [docs][godoc-url].\n\n# The Why?\n\nThis is an approach for load distribution across servers which I found\nconvinient to be used in a few projects I had worked on in the past. \n\nI think it is good to implement it from scratch to synthesize all my experience\nworking with it and share it with the community in hope it will help to build\nsomething good.\n\nThe key points of the package:\n1) Efficient concurrent read operations\n2) Correct handling of write operations (order of insertions on different\nprocesses doesn't matter; hash collisions are handled carefully).\n\n# Installation\n\n```bash\ngo get github.com/gobwas/hashring\n```\n\n# Usage\n\n```go\npackage main\n\nimport (\n\t\"strings\"\n\t\"io\"\n\n\t\"github.com/gobwas/hashring\"\n)\n\nfunc main() {\n\tvar ring hashring.Ring\n\t_ = ring.Insert(StringItem(\"server01\"))\n\t_ = ring.Insert(StringItem(\"server02\"))\n\t_ = ring.Insert(StringItem(\"server03\"))\n\t_ = ring.Insert(StringItem(\"server04\"))\n\n\tring.Get(StringItem(\"user01\")) // server04\n\tring.Get(StringItem(\"user02\")) // server04\n\tring.Get(StringItem(\"user03\")) // server02\n\tring.Get(StringItem(\"user04\")) // server01\n}\n\ntype StringItem string\n\nfunc (s StringItem) WriteTo(w io.Writer) (int64, error) {\n\tn, err := io.WriteString(w, string(s))\n\treturn int64(n), err\n}\n```\n\n# Contributing\n\nIf you find some bug or want to improve this package in any way feel free to\nfile an issue to discuss your findings or ideas.\n\n## Debugging\n\nNote that this package comes with built in _debug_ tracing (which only takes\nplace if you pass `hashring_trace` build tag, thanks to [gtrace][gtrace]\nzero-cost tracing).\n\nThis means that you can make hashring to print out each meaningful step it does\nto understand better what's happening under the hood.\n\nIt also consumes `hashring_debug` build tag, which allows you to hook into hash\ncalculation process and override the value it returns. For example, this was\nuseful to test hash collisions.\n\n## Magic factor\n\nMagic factor is a number of \"virtual\" nodes each item gets on a ring. The\nhigher this number, the more equal distribution of objects this ring produces\nand the more time is needed to update the ring.\n\nThe default value is picked through testing different sets of servers and\nobjects, however, for some datasets it may be enough to have smaller (or\nhigher) value of magic factor. There is a branch called [magic][magic] which\ncontains code used to generate statistics on distribution of objects depending\non magic factor value.\n\nHere is the sample result of distribution of 10M objects across 10 servers with\ndifferent magic factor values:\n\u003cimg alt=\"Magic factor plot\" src=\"https://github.com/gobwas/hashring/blob/magic/magicfactor.png\" width=\"800\"\u003e\n\n[godoc-image]:  https://godoc.org/github.com/gobwas/hashring?status.svg\n[godoc-url]:    https://godoc.org/github.com/gobwas/hashring\n[ci-badge]:     https://github.com/gobwas/hashring/actions/workflows/main.yml/badge.svg?branch=main\n[ci-url]:       https://github.com/gobwas/hashring/actions/workflows/main.yml\n[stanford-doc]: https://theory.stanford.edu/~tim/s16/l/l1.pdf\n[gtrace]:       https://github.com/gobwas/gtrace\n[magic]:        https://github.com/gobwas/hashring/tree/magic\n[magic-image]:  https://github.com/gobwas/hashring/blob/magic/magicfactor.png\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fhashring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobwas%2Fhashring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fhashring/lists"}