runtime: add execution concurrency limits

This commit is contained in:
a.tolmachev
2026-05-01 12:11:53 +00:00
parent 3d2d97c1e6
commit 8ac55ebcc2
13 changed files with 448 additions and 15 deletions
+14 -2
View File
@@ -20,7 +20,7 @@ use crate::{
service::AdminService,
state::AppState,
};
use crank_runtime::SecretCrypto;
use crank_runtime::{RuntimeExecutor, RuntimeLimits, SecretCrypto};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -57,8 +57,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.unwrap_or_else(|_| "Crank Owner".into()),
},
};
let runtime_limits = RuntimeLimits::from_env()?;
let secret_crypto = SecretCrypto::new(&env::var("CRANK_MASTER_KEY")?)?;
let service = AdminService::new(registry, storage_root, auth_settings, secret_crypto);
let runtime = RuntimeExecutor::with_limits(runtime_limits);
let service = AdminService::new_with_runtime(
registry,
storage_root,
auth_settings,
secret_crypto,
runtime,
);
service.bootstrap_admin_user().await?;
if env_flag("CRANK_DEMO_SEED") {
service.seed_demo_assets().await?;
@@ -68,6 +76,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let listener = TcpListener::bind(socket_addr).await?;
info!(
runtime_max_concurrent_unary = runtime_limits.max_concurrent_unary,
runtime_max_concurrent_window = runtime_limits.max_concurrent_window,
runtime_max_concurrent_sessions = runtime_limits.max_concurrent_sessions,
runtime_max_concurrent_jobs = runtime_limits.max_concurrent_jobs,
max_connections = pool_config.max_connections,
min_connections = pool_config.min_connections,
acquire_timeout_ms = pool_config.acquire_timeout_ms,