From a665132b230de39f16306536f803d525984427ed Mon Sep 17 00:00:00 2001 From: Nicolas Adrian Date: Mon, 10 Jun 2024 11:24:45 +0200 Subject: [PATCH] add proxy_host and proxy_port for FastHttpUser --- docs/increase-performance.rst | 2 +- examples/fast_http_locust.py | 2 ++ locust/contrib/fasthttp.py | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/increase-performance.rst b/docs/increase-performance.rst index 187750bf99..3ed92752aa 100644 --- a/docs/increase-performance.rst +++ b/docs/increase-performance.rst @@ -111,7 +111,7 @@ FastHttpUser class -------------------- .. autoclass:: locust.contrib.fasthttp.FastHttpUser - :members: network_timeout, connection_timeout, max_redirects, max_retries, insecure, concurrency, client_pool, rest, rest_ + :members: network_timeout, connection_timeout, max_redirects, max_retries, insecure, proxy_host, proxy_port, concurrency, client_pool, rest, rest_ FastHttpSession class diff --git a/examples/fast_http_locust.py b/examples/fast_http_locust.py index b2148caf40..42a72403b2 100644 --- a/examples/fast_http_locust.py +++ b/examples/fast_http_locust.py @@ -14,6 +14,8 @@ class WebsiteUser(FastHttpUser): # max_redirects = 5 # max_retries = 1 # network_timeout = 60.0 + # proxy_host = my-proxy.com + # proxy_port = 8080 @task def index(self): diff --git a/locust/contrib/fasthttp.py b/locust/contrib/fasthttp.py index a5d947a6a4..5aeb2c91f9 100644 --- a/locust/contrib/fasthttp.py +++ b/locust/contrib/fasthttp.py @@ -324,6 +324,12 @@ class FastHttpUser(User): Note that setting this value has no effect when custom client_pool was given, and you need to spawn a your own gevent pool to use it (as Users only have one greenlet). See test_fasthttp.py / test_client_pool_concurrency for an example.""" + proxy_host: str | None = None + """Parameter passed to FastHttpSession""" + + proxy_port: int | None = None + """Parameter passed to FastHttpSession""" + client_pool: HTTPClientPool | None = None """HTTP client pool to use. If not given, a new pool is created per single user.""" @@ -355,6 +361,8 @@ def __init__(self, environment) -> None: client_pool=self.client_pool, ssl_context_factory=self.ssl_context_factory, headers=self.default_headers, + proxy_host=self.proxy_host, + proxy_port=self.proxy_port, ) """ Instance of HttpSession that is created upon instantiation of User.