Make amount of open connections configurable

This commit is contained in:
syeopite 2021-05-23 04:03:31 -07:00
parent 43957e90ec
commit 5180aa1192
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
2 changed files with 7 additions and 3 deletions

View file

@ -15,6 +15,10 @@ Will use HTTP/3 to query the specified URL with the specified data, method and h
The port and address can be changed in config.toml, located in the default OS config location.
```toml
# Host address to bind to
host = "0.0.0.0"
# Port to listen on
port = 7192
# Amount of workers to process quic requests
open_connections = 5
```

View file

@ -24,7 +24,7 @@ CONFIG_FILE.touch(exist_ok=True)
with open(f"{CONFIG_FILE}") as config:
config = pytomlpp.loads(config.read())
if not config:
config = {"port": 7192, "host": "0.0.0.0"}
config = {"port": 7192, "host": "0.0.0.0", "open_connections": 5}
routes = web.RouteTableDef()
@ -52,7 +52,7 @@ async def post(request):
async def main():
asyncio.create_task(request_processor.request_worker())
[asyncio.create_task(request_processor.request_worker()) for _ in range(config.get("open_connections", 5))]
app = web.Application()
app.add_routes(routes)
return app
@ -61,4 +61,4 @@ async def main():
request_processor = quicclient.RequestProcessor()
if __name__ == '__main__':
web.run_app(main(), **config)
web.run_app(main(), port=config.get("port", 7912), host=config.get("host", "0.0.0.0"))