{"id":19252760,"url":"https://github.com/tomaszrewak/simple-throttler","last_synced_at":"2026-06-23T09:31:27.713Z","repository":{"id":125409492,"uuid":"173493271","full_name":"TomaszRewak/Simple-Throttler","owner":"TomaszRewak","description":"A simple and fast C++ throttler","archived":false,"fork":false,"pushed_at":"2019-03-03T06:45:14.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T16:53:21.695Z","etag":null,"topics":["cpp","fast","throttler"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/TomaszRewak.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":"2019-03-02T20:02:31.000Z","updated_at":"2019-03-03T06:45:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"a1d581d3-1194-4933-97c6-0fd1c62a472d","html_url":"https://github.com/TomaszRewak/Simple-Throttler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TomaszRewak/Simple-Throttler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomaszRewak%2FSimple-Throttler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomaszRewak%2FSimple-Throttler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomaszRewak%2FSimple-Throttler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomaszRewak%2FSimple-Throttler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomaszRewak","download_url":"https://codeload.github.com/TomaszRewak/Simple-Throttler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomaszRewak%2FSimple-Throttler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34684671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"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":["cpp","fast","throttler"],"created_at":"2024-11-09T18:28:19.861Z","updated_at":"2026-06-23T09:31:27.696Z","avatar_url":"https://github.com/TomaszRewak.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple-Throttler\nA simple C++ throttler implementation.\n\nThis throttler supports sending messages from multiple users. Each user can send only a certain number of messages within the period defined by the sliding window.\n\nBasic usage:\n```cpp\nauto throttler = make_message_throttler\u003cUserId, Message\u003e(\n  max_number_of_messages_per_user,\n  sliding_window_width,\n  message_consumer\n);\n\nthrottler.from(1).send(\"Message 1\");\nthrottler.from(1).send(\"Message 2\");\n\nthrottler.from(2).send(\"Message 3\");\n```\nor\n```cpp\nauto throttler = make_message_throttler\u003cUserId, Message\u003e(\n  max_number_of_messages_per_user,\n  sliding_window_width,\n  message_consumer\n);\n\nauto\u0026 first_client_interface = throttler.from(1);\nfirst_client_interface.send(\"Message 1\")\nfirst_client_interface.send(\"Message 2\");\n\nauto\u0026 second_client_interface = throttler.from(2);\nsecond_client_interface.send(\"Message 3\")\nsecond_client_interface.send(\"Message 4\");\n```\n\nTo be more specific:\n```cpp\n#include \"message_throttler_commons.hpp\"\n\n...\n\nauto throttler = make_message_throttler\u003cint, std::string\u003e(\n  4,\n  std::chrono::milliseconds{ 1000 },\n  [\u0026](const std::string\u0026 message) { std::cout \u003c\u003c \"Consumed: \" \u003c\u003c message \u003c\u003c endl; }\n  [\u0026](const std::string\u0026 message) { std::cout \u003c\u003c \"Disposed: \" \u003c\u003c message \u003c\u003c endl; }\n);\n\nthrottler.from(1).send(\"Hello\");\n```\n\nProperties:\n- I've separated single client interface from the main throttler. Thanks to this if one client wants to send multiple messages only one map lookup is required.\n- Throttler supports custom message types and client id types.\n- Complexity of the `send` method (of the client interface) is guaranteed to be O(1) no matter how long the sliding window is and how many messages are already registered in it. Also, after sending N (= sliding window size) messages the list of instructions performed to send [dispose] a message is always the same (which should make it easy for branch prediction algorithm).\n- `send` method (of the client interface) never allocates.\n- User can define his own data consumers (any callable functor will do). He can also listen for discarded messages.\n- By default (defined in `message_throttler_commons.hpp`) throttler uses chrono for timestamping. This behavior can be overwritten with any custom clock.\n- Calling the throttler's `from` method hashes the clientId only once. Map lookup is also performed only once, even if given client has not been registered yet.\n\nThis is a header only component. Apart from standard libs, it depends on boost's circular_buffer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomaszrewak%2Fsimple-throttler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomaszrewak%2Fsimple-throttler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomaszrewak%2Fsimple-throttler/lists"}