{"id":15069105,"url":"https://github.com/client-side/throttle","last_synced_at":"2025-10-05T06:31:14.304Z","repository":{"id":257793598,"uuid":"71383764","full_name":"client-side/throttle","owner":"client-side","description":"Java Rate Limiter Derived From Googles' Guava Implementation","archived":true,"fork":false,"pushed_at":"2017-12-31T14:29:24.000Z","size":176,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T11:47:00.162Z","etag":null,"topics":["java","rate-limiter","rate-limiting","throttle"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/client-side.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":"2016-10-19T17:43:12.000Z","updated_at":"2023-01-28T16:58:56.000Z","dependencies_parsed_at":"2024-10-04T01:45:13.483Z","dependency_job_id":null,"html_url":"https://github.com/client-side/throttle","commit_stats":null,"previous_names":["client-side/throttle","comodal/throttle"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client-side%2Fthrottle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client-side%2Fthrottle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client-side%2Fthrottle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/client-side%2Fthrottle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/client-side","download_url":"https://codeload.github.com/client-side/throttle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235370461,"owners_count":18979093,"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":["java","rate-limiter","rate-limiting","throttle"],"created_at":"2024-09-25T01:40:29.975Z","updated_at":"2025-10-05T06:31:13.686Z","avatar_url":"https://github.com/client-side.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Throttle [![Build Status](https://travis-ci.org/client-side/throttle.svg)](https://travis-ci.org/client-side/throttle) [![JCenter](https://api.bintray.com/packages/client-side/clients/throttle/images/download.svg) ](https://bintray.com/client-side/clients/throttle/_latestVersion) [![License](http://img.shields.io/badge/license-Apache--2-blue.svg?style=flat) ](LICENSE) [![codecov](https://codecov.io/gh/client-side/throttle/branch/master/graph/badge.svg)](https://codecov.io/gh/client-side/throttle)\n\n\u003eProvides a mechanism to limit the rate of access to a resource.\n\n### Usage\n\nA Throttle instance distributes permits at a desired rate, blocking if necessary until a permit is available.\n\n### Java Version Support\n\nVersion `0.2.6` is the latest version to support Java 8.  Future versions will support the latest Java version that is out at the time of release.\n\n###### Submit two tasks per second:\n\n```java\nThrottle throttle = Throttle.create(2.0); // 2 permits per second\n// ...\nvoid submitTasks(List\u003cRunnable\u003e tasks, Executor executor) {\n  for (Runnable task : tasks) {\n    throttle.acquire();\n    executor.execute(task);\n  }\n}\n```\n\n###### Cap data stream to 5kb per second:\n\n```java\nThrottle throttle = Throttle.create(5000.0); // 5000 permits per second\n// ...\nvoid submitPacket(byte[] packet) {\n  throttle.acquire(packet.length);\n  networkService.send(packet);\n}\n```\n\n### Changes From Guava Rate Limiter\n* Nanosecond instead of microsecond accuracy.\n* Uses a `ReentrantLock` instead of `synchronized` blocks to support optional fair acquisition ordering.\n* Factoring out an interface class, [Throttle](src/main/java/engineering/clientside/throttle/Throttle.java#L83), from the base abstract class.\n* Remove the need for any non-core-Java classes outside of the original [RateLimiter](https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/RateLimiter.java) and [SmoothRateLimiter](https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java) classes.\n* Remove the need for a [SleepingStopwatch](https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/RateLimiter.java#L395) or similar class instance.\n* Guava provides rate limiters with either _bursty_ or _warm-up_ behavior. Throttle provides only a single strict rate limiter implementation that will never exceed the desired rate limit over a one second period.\n* Throws checked InterruptedException's or unchecked CompletionException's with the cause set to the corresponding InterruptedException if interrupted.\n\n### Dependency Management\n```groovy\nrepositories {\n   jcenter()\n}\n\ndependencies {\n   compile 'engineering.clientside:throttle:+'\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclient-side%2Fthrottle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclient-side%2Fthrottle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclient-side%2Fthrottle/lists"}