Parallelize worker batch processing
This commit is contained in:
@@ -12,6 +12,8 @@ pub struct Config {
|
||||
|
||||
pub redis_url: String,
|
||||
|
||||
pub worker_concurrency: u32,
|
||||
|
||||
pub jwt_secret: String,
|
||||
pub jwt_expiry_hours: i64,
|
||||
|
||||
@@ -60,6 +62,12 @@ impl Config {
|
||||
let redis_url = env_string("REDIS_URL")
|
||||
.ok_or_else(|| AppError::new(ErrorCode::InvalidRequest, "缺少环境变量 REDIS_URL"))?;
|
||||
|
||||
let worker_concurrency = env_u32("WORKER_CONCURRENCY").unwrap_or_else(|| {
|
||||
std::thread::available_parallelism()
|
||||
.map(|v| v.get() as u32)
|
||||
.unwrap_or(4)
|
||||
});
|
||||
|
||||
let jwt_secret = env_string("JWT_SECRET")
|
||||
.ok_or_else(|| AppError::new(ErrorCode::InvalidRequest, "缺少环境变量 JWT_SECRET"))?;
|
||||
let jwt_expiry_hours = env_i64("JWT_EXPIRY_HOURS").unwrap_or(168);
|
||||
@@ -103,6 +111,7 @@ impl Config {
|
||||
database_url,
|
||||
database_max_connections,
|
||||
redis_url,
|
||||
worker_concurrency,
|
||||
jwt_secret,
|
||||
jwt_expiry_hours,
|
||||
api_key_pepper,
|
||||
|
||||
Reference in New Issue
Block a user