Skip to content

Commit

Permalink
feat(proxysql): add support to configure max database connection (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt authored Dec 3, 2024
1 parent be806a3 commit 033f000
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions agent/proxysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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 = [
(
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions agent/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ def proxysql_add_user():
data["username"],
data["password"],
data["database"],
data["max_connections"],
data["backend"],
)
return {"job": job}
Expand Down

0 comments on commit 033f000

Please sign in to comment.