Skip to content

Commit

Permalink
Timescale listener: Fix forwarding of pghost from command line. Add -…
Browse files Browse the repository at this point in the history
…-pgport and --pgdatabase.
  • Loading branch information
cyberw committed Mar 9, 2022
1 parent 93493db commit 1425b11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions locust_plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def add_checks_arguments(parser: configargparse.ArgumentParser):
env_var="PGHOST",
default="",
)
locust_dashboards.add_argument(
"--pgport",
type=str,
help="",
env_var="PGPORT",
default="",
)
locust_dashboards.add_argument(
"--pgpassword",
type=str,
Expand All @@ -79,6 +86,13 @@ def add_checks_arguments(parser: configargparse.ArgumentParser):
env_var="PGUSER",
default="",
)
locust_dashboards.add_argument(
"--pgdatabase",
type=str,
help="",
env_var="PGDATABASE",
default="",
)
run_info = parser.add_argument_group(
"locust-plugins - Run info",
"Extra run info for listeners",
Expand Down
6 changes: 4 additions & 2 deletions locust_plugins/listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ def on_start(self, environment: locust.env.Environment):
def _dbconn(self) -> psycopg2.extensions.connection:
try:
conn = psycopg2.connect(
host=os.environ.get("PGHOST", "localhost"),
password=self.env.parsed_options.pgpassword, # type: ignore[union-attr]
host=self.env.parsed_options.pghost,
password=self.env.parsed_options.pgpassword,
database=self.env.parsed_options.pgdatabase,
port=self.env.parsed_options.pgport,
keepalives_idle=120,
keepalives_interval=20,
keepalives_count=6,
Expand Down

0 comments on commit 1425b11

Please sign in to comment.