{"id":13878137,"url":"https://github.com/ejfinneran/ratelimit","last_synced_at":"2025-09-03T14:05:17.803Z","repository":{"id":1685695,"uuid":"2413506","full_name":"ejfinneran/ratelimit","owner":"ejfinneran","description":"A Redis-backed rate limiter written in Ruby","archived":false,"fork":false,"pushed_at":"2024-09-26T08:44:18.000Z","size":71,"stargazers_count":266,"open_issues_count":11,"forks_count":58,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-08-09T20:58:26.969Z","etag":null,"topics":["rate-limits","redis","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/ejfinneran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2011-09-19T06:09:10.000Z","updated_at":"2025-04-08T20:08:10.000Z","dependencies_parsed_at":"2024-01-18T05:26:56.024Z","dependency_job_id":"35e744d6-912f-4009-8323-f08d46c5ce8b","html_url":"https://github.com/ejfinneran/ratelimit","commit_stats":{"total_commits":77,"total_committers":14,"mean_commits":5.5,"dds":"0.35064935064935066","last_synced_commit":"d820ab193e56de04e75e0ce10d025e63361fc0a9"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ejfinneran/ratelimit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfinneran%2Fratelimit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfinneran%2Fratelimit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfinneran%2Fratelimit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfinneran%2Fratelimit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ejfinneran","download_url":"https://codeload.github.com/ejfinneran/ratelimit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfinneran%2Fratelimit/sbom","scorecard":{"id":370375,"data":{"date":"2025-08-11","repo":{"name":"github.com/ejfinneran/ratelimit","commit":"71910ee2f2259dd6c83dffe71dbea6c07fca866d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"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":"Code-Review","score":6,"reason":"Found 10/15 approved changesets -- score normalized to 6","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":"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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.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":"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/ci.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/ejfinneran/ratelimit/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/ejfinneran/ratelimit/ci.yml/master?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party 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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 1.0.1 not signed: https://api.github.com/repos/ejfinneran/ratelimit/releases/473737","Warn: release artifact 1.0.0 not signed: https://api.github.com/repos/ejfinneran/ratelimit/releases/375760","Warn: release artifact 1.0.1 does not have provenance: https://api.github.com/repos/ejfinneran/ratelimit/releases/473737","Warn: release artifact 1.0.0 does not have provenance: https://api.github.com/repos/ejfinneran/ratelimit/releases/375760"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 27 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-18T12:47:59.984Z","repository_id":1685695,"created_at":"2025-08-18T12:47:59.984Z","updated_at":"2025-08-18T12:47:59.984Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273321332,"owners_count":25084833,"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-09-02T02:00:09.530Z","response_time":77,"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":["rate-limits","redis","ruby"],"created_at":"2024-08-06T08:01:40.847Z","updated_at":"2025-09-03T14:05:17.741Z","avatar_url":"https://github.com/ejfinneran.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Ratelimit: Slow your roll\n\n[![Code Climate](https://codeclimate.com/github/ejfinneran/ratelimit.png)](https://codeclimate.com/github/ejfinneran/ratelimit)\n[![Coverage Status](https://img.shields.io/coveralls/ejfinneran/ratelimit.svg)](https://coveralls.io/r/ejfinneran/ratelimit)\n\nRatelimit provides a way to rate limit actions across multiple servers using Redis.  This is a port of RateLimit.js found [here](https://github.com/chriso/redback/blob/master/lib/advanced_structures/RateLimit.js) and inspired by [this post](https://gist.github.com/chriso/54dd46b03155fcf555adccea822193da).\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n``` rb\ngem 'ratelimit'\n```\n\nAnd then execute:\n\n``` sh\n$ bundle\n```\n\nOr install it yourself as:\n\n``` sh\n$ gem install ratelimit\n```\n\n## Usage\n\nMy example use case is bulk processing data against an external API.  This will allow you to limit multiple processes across multiple servers as long as they all use the same Redis database.\n\nAdd to the count for a given subject via add with a unique key. I've used the example of a phone number below but anything unique would work (URL, email address, etc.)\n\nYou can then fetch the number of executions for given interval in seconds via the count method.\n\n``` rb\nratelimit = Ratelimit.new(\"messages\")\n5.times do\n  ratelimit.add(phone_number)\nend\nratelimit.count(phone_number, 30)\n# =\u003e 5\n```\n\nYou can check if a given threshold has been exceeded or not. The following code checks if the currently rate is over 10 executions in the last 30 seconds or not.\n\n``` rb\nratelimit.exceeded?(phone_number, threshold: 10, interval: 30)\n# =\u003e false\nratelimit.within_bounds?(phone_number, threshold: 10, interval: 30)\n# =\u003e true\n```\n\nYou can also pass a block that will only get executed if the given threshold is within bounds. Beware, this code blocks until the block can be run.\n\n``` rb\nratelimit.exec_within_threshold phone_number, threshold: 10, interval: 30 do\n  some_rate_limited_code\n  ratelimit.add(phone_number)\nend\n```\n\n### Connecting to an external Redis instance\n\nBy default, Ratelimit will try to connect to a Redis server on `127.0.0.1:6379` and this works great when you have everything in one place. However, when you have a separate Redis server, you will need to make a few changes to specify its location.\n\nTo do so, instantiate a redis client pointing to the right server (if you don't have one instance already) and pass it in the constructor.\n\n``` rb\nredis = Redis.new(host: \"10.0.1.1\", port: 6380, db: 15)\n...\nratelimit = Ratelimit.new(\"messages\", redis: redis)\n```\n\n## Documentation\n\nFull documentation can be found [here.](http://rubydoc.info/github/ejfinneran/ratelimit/frames)\n\n## Contributing\n\n1. Fork it ( https://github.com/ejfinneran/ratelimit/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejfinneran%2Fratelimit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fejfinneran%2Fratelimit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejfinneran%2Fratelimit/lists"}