tokio-patterns

Provide Tokio patterns for worker pools, pub/sub, timeouts, retries, and graceful shutdown.

8|2|Updated Oct 17, 2025
One-click install
npx skills add https://github.com/geoffjay/claude-plugins --skill tokio-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tokio-patterns
Source: https://github.com/geoffjay/claude-plugins/tree/main/plugins/rust-tokio-expert/skills/tokio-patterns
Command: npx skills add https://github.com/geoffjay/claude-plugins --skill tokio-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides common patterns and idioms for building robust async applications with Tokio.

Core Features & Use Cases

  • Worker Pool Pattern: Limit concurrent task execution using a semaphore to avoid overload and ensure fair scheduling.
  • Request-Response Pattern: Use oneshot channels for precise request-response communication.
  • Pub/Sub with Channels: Implement publish/subscribe messaging with Tokio channels.
  • Timeout Pattern: Wrap operations with timeout to fail fast on long-running tasks.
  • Retry with Exponential Backoff: Retry failed operations with backoff to improve resilience.
  • Graceful Shutdown: Coordinate clean shutdown across components.

Quick Start

Use the tokio-patterns skill to implement a worker pool with a semaphore and a graceful shutdown in a sample service.

Frequently Asked Questions about tokio-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure concurrent tasks in Rust without overwhelming the system?

Worker pool patterns with semaphores limit concurrent task execution to prevent overload. Tokio patterns provide semaphore-based coordination to cap active tasks, ensure fair scheduling, and maintain system stability under concurrent workloads.

What's the best way to implement request-response communication in async Rust?

Oneshot channels enable precise request-response messaging in async Rust. Tokio patterns show how to pair oneshot channels with task spawning to create reliable bidirectional communication without shared state complexity.

How do I add timeout handling to long-running async operations?

Wrap async operations with timeout functions to fail fast and prevent indefinite hangs. Tokio patterns demonstrate timeout wrapping techniques to handle operations that exceed acceptable durations reliably.

Can I implement publish-subscribe messaging with Tokio channels?

Yes, Tokio channels support pub/sub by cloning broadcast senders across tasks. Tokio patterns provide idiomatic implementations of message broadcasting where multiple subscribers receive published events concurrently.

How do I build retry logic with exponential backoff in async code?

Retry patterns combine loop logic with exponential backoff delays to handle transient failures. Tokio patterns show how to implement resilient retry strategies that increase wait time between attempts without blocking the runtime.

What's the correct way to shut down async services gracefully?

Graceful shutdown coordinates component teardown through cancellation tokens and channel signaling. Tokio patterns demonstrate orderly shutdown sequences that allow in-flight tasks to complete while preventing new work acceptance.