Building async Rust applications requires understanding complex concurrency patterns. This skill provides production-ready Tokio patterns for tasks, channels, streams, and graceful shutdown handling.
Descargar el ZIP de la skill
Subir en Claude
Ve a Configuración → Capacidades → Skills → Subir skill
Activa y empieza a usar
Pruébalo
Usando "rust-async-patterns". Create an async function that fetches data from 5 URLs with a concurrency limit of 3
Resultado esperado:
Uses stream::iter with buffer_unordered(3) to process URLs concurrently, returning a Vec of Results with proper error handling for each fetch operation.
Usando "rust-async-patterns". How do I share state between async tasks safely?
Resultado esperado:
Recommends Arc<RwLock<T>> for read-heavy workloads or Arc<Mutex<T>> for write-heavy scenarios, with examples showing .read().await and .write().await patterns.
Auditoría de seguridad
SeguroAll 51 static analysis findings are false positives. The skill contains documentation-only markdown files with Rust code examples. The static analyzer incorrectly flagged: markdown code fence backticks as shell execution, tokio::spawn (async task spawning) as process execution, SQL queries as system reconnaissance, and example URLs as hardcoded secrets. No executable code or security risks present.
Puntuación de calidad
Lo que puedes crear
Network Service Development
Build concurrent HTTP servers or WebSocket handlers using Tokio tasks and channels for request distribution and graceful shutdown.
Data Pipeline Implementation
Process streaming data with async streams, buffer_unordered for controlled concurrency, and proper error propagation.
Async Code Debugging
Diagnose deadlock issues, understand task cancellation, and implement proper tracing instrumentation for async applications.
Prueba estos prompts
Help me set up a basic Tokio async application with proper error handling. I need to fetch data from multiple URLs concurrently and handle any failures gracefully.
I need to implement a worker pool pattern where multiple producer tasks send work items to consumer tasks. Show me how to use mpsc channels with proper shutdown handling.
My async server needs to handle SIGINT/SIGTERM and shutdown cleanly. All in-flight requests should complete within 30 seconds before forced termination. Implement this with CancellationToken.
I'm processing a large dataset as a stream. Implement chunked processing with buffer_unordered to limit concurrency to 10 items, with proper error handling for failed items.
Mejores prácticas
- Use tokio::select! for racing futures and implementing cancellation points in long-running tasks
- Prefer channels over shared state for task communication to avoid deadlocks and reduce lock contention
- Instrument async functions with tracing attributes and respect CancellationToken for graceful shutdown
Evitar
- Blocking async code with std::thread::sleep or blocking I/O operations that starve the runtime
- Holding locks across await points which can cause deadlocks when multiple tasks contend for the same locks
- Spawning unbounded tasks without semaphores or JoinSet limits leading to resource exhaustion
Preguntas frecuentes
What is the difference between tokio::spawn and std::thread::spawn?
When should I use channels vs shared state (Mutex/RwLock)?
How do I handle timeouts in async Rust?
What is the purpose of async-trait crate?
How can I debug async Rust applications?
What is buffer_unordered and when should I use it?
Detalles del desarrollador
Autor
sickn33Licencia
MIT
Repositorio
https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/rust-async-patternsRef.
main
Estructura de archivos