From c35e37a90dd086247896d764aff20c3d5afd6114 Mon Sep 17 00:00:00 2001 From: Wout Feys Date: Tue, 3 Sep 2024 15:44:05 +0200 Subject: [PATCH] Use clientside ratelimiting with same parameters as Node.js --- .../background_process/aikido_background_process.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aikido_firewall/background_process/aikido_background_process.py b/aikido_firewall/background_process/aikido_background_process.py index 1d660ad4..284d75ee 100644 --- a/aikido_firewall/background_process/aikido_background_process.py +++ b/aikido_firewall/background_process/aikido_background_process.py @@ -15,7 +15,9 @@ ) from aikido_firewall.helpers.check_env_for_blocking import check_env_for_blocking from aikido_firewall.helpers.token import get_token_from_env -from aikido_firewall.background_process.api.http_api import ReportingApiHTTP +from aikido_firewall.background_process.api.http_api_ratelimited import ( + ReportingApiHTTPRatelimited, +) from .commands import process_incoming_command EMPTY_QUEUE_INTERVAL = 5 # 5 seconds @@ -70,7 +72,11 @@ def reporting_thread(self): ) # Create an event scheduler self.send_to_connection_manager(event_scheduler) - api = ReportingApiHTTP("https://guard.aikido.dev/") + api = ReportingApiHTTPRatelimited( + "https://guard.aikido.dev/", + max_events_per_interval=2, + interval_in_ms=15 * 1000, + ) # We need to pass along the scheduler so that the heartbeat also gets sent self.connection_manager = CloudConnectionManager( block=check_env_for_blocking(),