1
0
mirror of https://github.com/zedeus/nitter.git synced 2026-04-09 15:22:18 -04:00

Make maxConcurrentReqs configurable (#1341)

This commit is contained in:
jackyzy823
2025-12-08 17:05:08 +08:00
committed by GitHub
parent 51b54852dc
commit baeaf685d3
5 changed files with 12 additions and 5 deletions

View File

@@ -3,14 +3,17 @@ import std/[asyncdispatch, times, json, random, strutils, tables, packedsets, os
import types, consts
import experimental/parser/session
# max requests at a time per session to avoid race conditions
const
maxConcurrentReqs = 2
hourInSeconds = 60 * 60
const hourInSeconds = 60 * 60
var
sessionPool: seq[Session]
enableLogging = false
# max requests at a time per session to avoid race conditions
maxConcurrentReqs = 2
proc setMaxConcurrentReqs*(reqs: int) =
if reqs > 0:
maxConcurrentReqs = reqs
template log(str: varargs[string, `$`]) =
echo "[sessions] ", str.join("")

View File

@@ -42,7 +42,8 @@ proc getConfig*(path: string): (Config, parseCfg.Config) =
proxy: cfg.get("Config", "proxy", ""),
proxyAuth: cfg.get("Config", "proxyAuth", ""),
apiProxy: cfg.get("Config", "apiProxy", ""),
disableTid: cfg.get("Config", "disableTid", false)
disableTid: cfg.get("Config", "disableTid", false),
maxConcurrentReqs: cfg.get("Config", "maxConcurrentReqs", 2)
)
return (conf, cfg)

View File

@@ -39,6 +39,7 @@ setMaxHttpConns(cfg.httpMaxConns)
setHttpProxy(cfg.proxy, cfg.proxyAuth)
setApiProxy(cfg.apiProxy)
setDisableTid(cfg.disableTid)
setMaxConcurrentReqs(cfg.maxConcurrentReqs)
initAboutPage(cfg.staticDir)
waitFor initRedisPool(cfg)

View File

@@ -277,6 +277,7 @@ type
proxyAuth*: string
apiProxy*: string
disableTid*: bool
maxConcurrentReqs*: int
rssCacheTime*: int
listCacheTime*: int