{"id":26651942,"url":"https://github.com/haylockgrant/compute_rated","last_synced_at":"2026-02-21T09:31:16.111Z","repository":{"id":283913870,"uuid":"943509497","full_name":"HaylockGrant/compute_rated","owner":"HaylockGrant","description":"ComputeRated, a leaky bucket rate limiter optimized for compute time limits.          This library allows you to rate-limit operations based on compute time,     with support for checking capacity, adding compute time, and waiting     for capacity to be available.","archived":false,"fork":false,"pushed_at":"2025-03-06T06:05:33.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-20T21:55:34.736Z","etag":null,"topics":["ai-api","bucket","elixir","leaky-bucket","otp","phoenix","rate-limit","rate-limiting","rate-limits"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HaylockGrant.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,"zenodo":null}},"created_at":"2025-03-05T20:28:10.000Z","updated_at":"2025-03-06T06:05:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4b6f9c5-47b6-4ee1-8487-3affc6330886","html_url":"https://github.com/HaylockGrant/compute_rated","commit_stats":null,"previous_names":["haylockgrant/compute_rated"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HaylockGrant/compute_rated","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaylockGrant%2Fcompute_rated","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaylockGrant%2Fcompute_rated/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaylockGrant%2Fcompute_rated/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaylockGrant%2Fcompute_rated/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HaylockGrant","download_url":"https://codeload.github.com/HaylockGrant/compute_rated/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaylockGrant%2Fcompute_rated/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266053824,"owners_count":23869496,"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":["ai-api","bucket","elixir","leaky-bucket","otp","phoenix","rate-limit","rate-limiting","rate-limits"],"created_at":"2025-03-25T03:39:07.487Z","updated_at":"2026-02-21T09:31:16.065Z","avatar_url":"https://github.com/HaylockGrant.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ComputeRated\n\nA leaky bucket rate limiter optimized for compute time limits.\n\nComputeRated allows you to:\n- Check if adding compute time would exceed a bucket's capacity\n- Add compute time to a bucket\n- Wait until a bucket has sufficient capacity or is fully depleted\n- Track compute time usage over specified time windows\n\n## Installation\n\nThe package can be installed by adding `compute_rated` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:compute_rated, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\n```elixir\n# Check if adding 100 units of compute time would exceed a bucket's capacity\n{:ok, current, remaining} = ComputeRated.check_rate(\"my-bucket\", 60_000, 1000, 100)\n\n# Add 100 units of compute time to a bucket\n{:ok, current, remaining} = ComputeRated.add_compute_time(\"my-bucket\", 60_000, 1000, 100)\n\n# Wait until there's enough capacity for an estimated 200 units\n:ok = ComputeRated.wait_for_capacity(\"my-bucket\", 60_000, 1000, 200)\n\n# Wait until the bucket is completely empty\n:ok = ComputeRated.wait_for_capacity(\"my-bucket\", 60_000, 1000, nil, true)\n\n# Delete a bucket\n:ok = ComputeRated.delete_bucket(\"my-bucket\")\n```\n\n## Configuration\n\nComputeRated can be configured in your `config.exs`:\n\n```elixir\nconfig :compute_rated,\n  timeout: 90_000_000,       # bucket maximum lifetime (25 hours)\n  cleanup_rate: 60_000,      # cleanup every minute\n  ets_table_name: :compute_rated_buckets,  # the registered name of the ETS table\n  persistent: false          # whether to persist the buckets to disk\n```\n\n## Third-Party Attributions\n  This project includes modified code from ExRated by Glenn Rempe (https://github.com/grempe/ex_rated).\n  For full attribution and license information, please see the ATTRIBUTION file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaylockgrant%2Fcompute_rated","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaylockgrant%2Fcompute_rated","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaylockgrant%2Fcompute_rated/lists"}