From 033f00004e95f7c220b1f6c20e6863f731656ec6 Mon Sep 17 00:00:00 2001 From: Tanmoy Sarkar <57363826+tanmoysrt@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:08:26 +0530 Subject: [PATCH] feat(proxysql): add support to configure max database connection (#145) --- agent/proxysql.py | 15 +++++++++++---- agent/web.py | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/agent/proxysql.py b/agent/proxysql.py index 077469ad..c03015ff 100644 --- a/agent/proxysql.py +++ b/agent/proxysql.py @@ -25,9 +25,16 @@ def proxysql_execute(self, command): return self.execute(command) @job("Add User to ProxySQL") - def add_user_job(self, username, password, database, backend): + def add_user_job( + self, + username: str, + password: str, + database: str, + max_connections: int, + backend: dict, + ): self.add_backend(backend) - self.add_user(username, password, database, backend) + self.add_user(username, password, database, max_connections, backend) @job("Add Backend to ProxySQL") def add_backend_job(self, backend): @@ -48,7 +55,7 @@ def add_backend(self, backend): self.proxysql_execute(command) @step("Add User to ProxySQL") - def add_user(self, username, password, database, backend): + def add_user(self, username: str, password: str, database: str, max_connections: int, backend: dict): backend_id = backend["id"] commands = [ ( @@ -57,7 +64,7 @@ def add_user(self, username, password, database, backend): "use_ssl, max_connections) " "VALUES ( " f'"{username}", "{password}", {backend_id}, "{database}", ' - "1, 16)" + f"1, {max_connections})" ), "LOAD MYSQL USERS TO RUNTIME", "SAVE MYSQL USERS FROM RUNTIME", diff --git a/agent/web.py b/agent/web.py index 28264039..aa114633 100644 --- a/agent/web.py +++ b/agent/web.py @@ -1036,6 +1036,7 @@ def proxysql_add_user(): data["username"], data["password"], data["database"], + data["max_connections"], data["backend"], ) return {"job": job}