salvo-concurrency-limiter
Limit concurrent requests to protect resources. Use for file uploads, expensive operations, and preventing resource exhaustion.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Limit concurrent requests to protect resources. Use for file uploads, expensive operations, and preventing resource exhaustion.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Guide for using RBatis v4 Rust ORM framework. Use when implementing database CRUD operations, writing dynamic SQL with py_sql or html_sql macros, configuring database connections, managing transactions, implementing interceptors, syncing table structures, or integrating RBatis into Genies microservices. Also use when the user asks about RBatis usage patterns, query building, or database operations in Rust.
Genies 前后端接口规范。Use when designing API contracts, defining field naming conventions, date/time formats, response models, pagination, error handling, or ID strategies between Genies backend and frontend (Web/Android/OHOS).
Guide for using flyway-rs database migration framework with RBatis. Use when implementing database schema migrations, managing SQL changelog files, configuring migration runners, handling multi-database migrations, or integrating database versioning into Genies microservices.
Guide for developing Rust microservices using Genies framework following Java DDD layering principles. Use when creating new microservices, designing aggregate roots, implementing domain events, organizing service layers, setting up Flyway migrations, or structuring a DDD-based Genies project.
Genies framework unified skill hub. Use when you need to find the right skill for any Genies framework task, including authentication, authorization, caching, configuration, database, DDD microservices, Dapr messaging, macros, K8s deployment, testing, API conventions, gateway proxy, or Salvo web framework features. Also use when the user asks about Genies framework capabilities, asks which skill to use, or wants a quick overview of available Genies skills.
Guide for using the Genies Rust microservice framework with DDD and Dapr. Use when developing with Genies, creating aggregates, domain events, Dapr subscriptions, Casbin field-level permissions, configuration management, or when the user asks about Genies framework usage patterns.
| name | salvo-concurrency-limiter |
| description | Limit concurrent requests to protect resources. Use for file uploads, expensive operations, and preventing resource exhaustion. |
| version | 0.89.3 |
| tags | ["performance","concurrency","limiter"] |
This skill helps limit concurrent requests in Salvo applications.
Concurrency limiter is built into Salvo core:
[dependencies]
salvo = "0.89.3"
use salvo::prelude::*;
#[handler]
async fn upload(req: &mut Request, res: &mut Response) {
tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
res.render("Upload complete");
}
#[tokio::main]
async fn main() {
let router = Router::new()
.push(
Router::with_path("upload")
.hoop(max_concurrency(1))
.post(upload)
);
let acceptor = TcpListener::new("0.0.0.0:8080").bind().await;
Server::new(acceptor).serve(router).await;
}
use salvo::prelude::*;
#[tokio::main]
async fn main() {
let router = Router::new()
.push(
Router::with_path("upload")
.hoop(max_concurrency(2))
.post(upload_handler)
)
.push(
Router::with_path("reports/generate")
.hoop(max_concurrency(1))
.post(generate_report)
)
.push(
Router::with_path("api/{**rest}")
.hoop(max_concurrency(100))
.goal(api_handler)
)
.push(Router::with_path("health").get(health_check));
let acceptor = TcpListener::new("0.0.0.0:8080").bind().await;
Server::new(acceptor).serve(router).await;
}
use salvo::prelude::*;
use salvo::rate_limiter::{BasicQuota, FixedGuard, MokaStore, RateLimiter, RemoteIpIssuer};
#[tokio::main]
async fn main() {
let rate_limiter = RateLimiter::new(
FixedGuard::new(),
MokaStore::new(),
RemoteIpIssuer,
BasicQuota::per_second(10),
);
let router = Router::new()
.push(
Router::with_path("api/{**rest}")
.hoop(rate_limiter)
.hoop(max_concurrency(50))
.goal(api_handler)
);
let acceptor = TcpListener::new("0.0.0.0:8080").bind().await;
Server::new(acceptor).serve(router).await;
}
use std::time::Duration;
use salvo::prelude::*;
#[tokio::main]
async fn main() {
let router = Router::new()
.push(
Router::with_path("process")
.hoop(Timeout::new(Duration::from_secs(30)))
.hoop(max_concurrency(5))
.post(process_handler)
);
let acceptor = TcpListener::new("0.0.0.0:8080").bind().await;
Server::new(acceptor).serve(router).await;
}
let router = Router::new()
.push(
Router::with_path("resize")
.hoop(max_concurrency(num_cpus::get()))
.post(resize_image)
);
let db_pool_size = 10;
let router = Router::new()
.push(
Router::with_path("heavy-query")
.hoop(max_concurrency(db_pool_size))
.get(heavy_query_handler)
);
let router = Router::new()
.push(
Router::with_path("external")
.hoop(max_concurrency(5))
.get(call_external_api)
);
| Operation Type | Recommended Limit |
|---|---|
| File uploads | 1-5 |
| Image processing | CPU cores |
| Report generation | 1-2 |
| Database heavy queries | DB pool size |
| External API calls | API limit |
| General API endpoints | 50-200 |