{"id":28153786,"url":"https://github.com/savonarola/token_bucket","last_synced_at":"2025-10-28T09:03:51.785Z","repository":{"id":62430469,"uuid":"132365723","full_name":"savonarola/token_bucket","owner":"savonarola","description":"Rate limiter implementing Token Bucket algorithm","archived":false,"fork":false,"pushed_at":"2018-05-06T20:40:59.000Z","size":11,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-17T14:23:13.192Z","etag":null,"topics":["bucket-algorithm","rate-limits"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/savonarola.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}},"created_at":"2018-05-06T18:36:21.000Z","updated_at":"2019-10-23T07:03:57.000Z","dependencies_parsed_at":"2022-11-01T20:19:21.069Z","dependency_job_id":null,"html_url":"https://github.com/savonarola/token_bucket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/savonarola/token_bucket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savonarola%2Ftoken_bucket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savonarola%2Ftoken_bucket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savonarola%2Ftoken_bucket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savonarola%2Ftoken_bucket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/savonarola","download_url":"https://codeload.github.com/savonarola/token_bucket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savonarola%2Ftoken_bucket/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270287525,"owners_count":24558625,"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-08-13T02:00:09.904Z","response_time":66,"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":["bucket-algorithm","rate-limits"],"created_at":"2025-05-15T06:12:17.704Z","updated_at":"2025-10-28T09:03:46.751Z","avatar_url":"https://github.com/savonarola.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/savonarola/token_bucket.svg?branch=master)](https://travis-ci.org/savonarola/token_bucket)\n[![Coverage Status](https://coveralls.io/repos/github/savonarola/token_bucket/badge.svg?branch=master)](https://coveralls.io/github/savonarola/token_bucket?branch=master)\n\n\u003ca href=\"https://funbox.ru\"\u003e\n  \u003cimg src=\"http://funbox.ru/badges/sponsored_by_funbox_compact.svg\" alt=\"Sponsored by FunBox\" width=250 /\u003e\n\u003c/a\u003e\n\n# TokenBucket\n\nRate limiter implementing Token Bucket algorithm https://en.wikipedia.org/wiki/Token_bucket\n\n## Installation\n\nThe package can be installed\nby adding `token_bucket` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:token_bucket, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\n```elixir\n    # Bucket size 10000, add 1000 tokens to bucket each second.\n    # This allows peaks of load in 10000 tokens (requests) in a moment and still keeps average load\n    # below 1000 tokens per second.\n    {:ok, pid} = TokenBucket.start_link(10_000, 1_000)\n\n    true = TokenBucket.consume(pid, 1)\n\n    # Equivalently\n    true = TokenBucket.consume(pid)\n```\n\nMore precise tuning:\n\n```elixir\n    # Bucket size 2, add 1 token to bucket each 100 ms.\n    {:ok, pid} = TokenBucket.start_link(2, {1, 100})\n\n    true = TokenBucket.consume(pid)\n    true = TokenBucket.consume(pid)\n    false = TokenBucket.consume(pid)\n\n    :timer.sleep(120)\n\n    true = TokenBucket.consume(pid)\n    false = TokenBucket.consume(pid)\n```\n\nUsing arbitrary `GenServer` options:\n\n```elixir\n    # Register locally as `:my_limiter`.\n    {:ok, pid} = TokenBucket.start_link(10_000, 1_000, name: :my_limiter)\n```\n\n## LICENSE\n\nThis software is licensed under [MIT License](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavonarola%2Ftoken_bucket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsavonarola%2Ftoken_bucket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavonarola%2Ftoken_bucket/lists"}