-
Notifications
You must be signed in to change notification settings - Fork 0
Add config option to control maximum gateway worker thread count #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: base-sha/17fa5ee48109ff6c245bd30d18e9910d3e81e3b1
Are you sure you want to change the base?
Changes from all commits
75c0c9b
d2f5d18
4620fe8
24278fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -655,6 +655,8 @@ def populate_edge_configuration( | |||||||||||
GATEWAY_LISTEN, | ||||||||||||
) = populate_edge_configuration(os.environ) | ||||||||||||
|
||||||||||||
GATEWAY_WORKER_COUNT = int(os.environ.get("GATEWAY_WORKER_COUNT") or 1000) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The fallback of 1000 for
Suggested change
|
||||||||||||
|
||||||||||||
# IP of the docker bridge used to enable access between containers | ||||||||||||
DOCKER_BRIDGE_IP = os.environ.get("DOCKER_BRIDGE_IP", "").strip() | ||||||||||||
|
||||||||||||
|
@@ -1114,6 +1116,7 @@ def use_custom_dns(): | |||||||||||
"EXTRA_CORS_ALLOWED_ORIGINS", | ||||||||||||
"EXTRA_CORS_EXPOSE_HEADERS", | ||||||||||||
"GATEWAY_LISTEN", | ||||||||||||
"GATEWAY_WORKER_THREAD_COUNT", | ||||||||||||
"HOSTNAME", | ||||||||||||
"HOSTNAME_FROM_LAMBDA", | ||||||||||||
"KINESIS_ERROR_PROBABILITY", | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -82,15 +82,19 @@ class GatewayServer(HypercornServer): | |||||
""" | ||||||
|
||||||
def __init__( | ||||||
self, gateway: Gateway, listen: HostAndPort | list[HostAndPort], use_ssl: bool = False | ||||||
self, | ||||||
gateway: Gateway, | ||||||
listen: HostAndPort | list[HostAndPort], | ||||||
use_ssl: bool = False, | ||||||
threads: int | None = None, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using
Suggested change
|
||||||
): | ||||||
""" | ||||||
Creates a new GatewayServer instance. | ||||||
|
||||||
:param gateway: which will be served by this server | ||||||
:param port: defining the port of this server instance | ||||||
:param bind_address: to bind this server instance to. Can be a host string or a list of host strings. | ||||||
:param listen: defining the address and port pairs this server binds to. Can be a list of host and port pairs. | ||||||
:param use_ssl: True if the LocalStack cert should be loaded and HTTP/HTTPS multiplexing should be enabled. | ||||||
:param threads: Number of worker threads the gateway will use. | ||||||
""" | ||||||
# build server config | ||||||
config = Config() | ||||||
|
@@ -109,7 +113,7 @@ def __init__( | |||||
|
||||||
# build gateway | ||||||
loop = asyncio.new_event_loop() | ||||||
app = AsgiGateway(gateway, event_loop=loop) | ||||||
app = AsgiGateway(gateway, event_loop=loop, threads=threads) | ||||||
|
||||||
# start serving gateway | ||||||
super().__init__(app, config, loop) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or
for default parameter handling is clear but consider centralizing default values.While the use of
or
for providing a default value is straightforward, centralizing default values (e.g., as constants) can make future adjustments and readability better.