Expand description
Docket: Distributed task queue for FastMCP.
Provides distributed task queue capabilities with support for multiple backends:
- Memory: In-process queue for testing and development
- Redis: Distributed queue for production deployments
§Architecture
┌────────────────────────────────────────────────────────────┐
│ Docket │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ DocketClient │ │ Worker Pool │ │
│ │ (task submit) │ │ (processing) │ │
│ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │
│ └──────────┬─────────┘ │
│ ▼ │
│ ┌────────────────────┐ │
│ │ DocketBackend │ │
│ └─────────┬──────────┘ │
│ │ │
│ ┌─────────────┼─────────────┐ │
│ ▼ ▼ ▼ │
│ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
│ │ Memory │ │ Redis │ │ Future │ │
│ │ Backend │ │ Backend │ │ Backends │ │
│ └─────────┘ └─────────┘ └─────────────┘ │
└────────────────────────────────────────────────────────────┘§Usage
ⓘ
use fastmcp_server::docket::{Docket, DocketSettings, Worker};
// Create with memory backend (testing/development)
let docket = Docket::memory();
// Create with Redis backend (production)
let settings = DocketSettings::redis("redis://localhost:6379");
let docket = Docket::new(settings)?;
// Submit a task
let task_id = docket.submit("process_data", json!({"input": "data"})).await?;
// Create a worker
let worker = docket.worker()
.subscribe("process_data", |task| async move {
// Process the task
Ok(json!({"result": "processed"}))
})
.build();
// Start processing
worker.run().await?;Structs§
- Docket
- Docket distributed task queue.
- Docket
Settings - Settings for configuring a Docket instance.
- Docket
Task - A queued task in the Docket system.
- Memory
Docket Backend - In-memory Docket backend for testing and development.
- Queue
Stats - Queue statistics.
- Redis
Settings - Redis connection settings.
- Submit
Options - Options for submitting a task.
- Worker
- A worker that processes tasks from the queue.
- Worker
Builder - Builder for creating workers.
Enums§
- Docket
Backend Type - Backend type configuration.
- Docket
Error - Errors that can occur in Docket operations.
Traits§
- Docket
Backend - Backend trait for Docket storage.
Type Aliases§
- Docket
Result - Result type for Docket operations.
- Shared
Docket - Thread-safe handle to a Docket.
- Task
Handler Fn - Task handler function type.