Generate async Rust code using Tokio with proper task spawning, channels, error handling, and graceful shutdown.
Act as a Rust async/Tokio expert. Generate an async service implementation with production-grade patterns. ## Input Parameters - **Service Purpose**: [SERVICE_DESCRIPTION] - **I/O Operations**: [IO_OPERATIONS] - **Concurrency Model**: [CONCURRENCY_NEEDS] - **Shutdown Signal**: [SHUTDOWN_MECHANISM] ## Instructions 1. Use tokio::spawn for independent concurrent tasks. 2. Implement tokio::select! for multiplexing futures. 3. Use mpsc/broadcast/watch channels for inter-task communication. 4. Handle errors with anyhow for applications or thiserror for libraries. 5. Implement graceful shutdown using tokio::signal and CancellationToken. 6. Use tokio::time for timeouts and retries with exponential backoff. 7. Add tracing instrumentation with #[instrument] attributes. ## Output Return the async service, task modules, channel setup, and a main.rs that wires everything together with tokio::main.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.0 Flash.
Describe the service purpose, list I/O operations (HTTP, DB, file), specify concurrency needs, and choose the shutdown signal (SIGTERM, Ctrl+C).
Initial release
Sign in and download this prompt to leave a review.