Skip to content

Commit

Permalink
feat(proxysql): add support to configure max database connection
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt committed Nov 29, 2024
1 parent be806a3 commit 4f3cc90
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,
backend: dict,
max_connections: int = 4,
):
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 @@ -1037,6 +1037,7 @@ def proxysql_add_user():
data["password"],
data["database"],
data["backend"],
max_connections=data["max_connections"],
)
return {"job": job}

Expand Down

0 comments on commit 4f3cc90

Please sign in to comment.