一键导入
storm-api-queues
Implement in-memory queues using the Storm.Api framework with ItemQueue, BufferedItemQueue, ThrottledBufferedItemQueue, and queue workers.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implement in-memory queues using the Storm.Api framework with ItemQueue, BufferedItemQueue, ThrottledBufferedItemQueue, and queue workers.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | storm-api-queues |
| description | Implement in-memory queues using the Storm.Api framework with ItemQueue, BufferedItemQueue, ThrottledBufferedItemQueue, and queue workers. |
| user-invocable | true |
| disable-model-invocation | false |
You are helping implement in-memory queues using the Storm.Api framework. Follow all patterns below exactly. For global rules (logging, extensions, anti-patterns), see /storm-api.
The user's request: $ARGUMENTS
Storm.Api provides channel-based in-memory queues for decoupling producers from consumers. Queues are used with background workers (see /storm-api-workers) to process items asynchronously. Three queue types are available, all built on System.Threading.Channels.
Unbounded queue where each Dequeue returns a single item:
using Storm.Api.Queues;
var queue = new ItemQueue<WorkItem>();
queue.Queue(new WorkItem { ... });
WorkItem item = await queue.Dequeue(cancellationToken);
Collects items into arrays of up to bufferSize. Dequeue blocks until the buffer is full:
var queue = new BufferedItemQueue<LogEntry>(bufferSize: 50);
LogEntry[] batch = await queue.Dequeue(cancellationToken);
Like BufferedItemQueue, but returns a partial batch if a timeout elapses:
var queue = new ThrottledBufferedItemQueue<LogEntry>(
bufferSize: 100,
throttlingTime: TimeSpan.FromSeconds(5)
);
// Returns when 100 items collected OR 5 seconds after first item
LogEntry[] batch = await queue.Dequeue(cancellationToken);
| Interface | Input → Output | Use case |
|---|---|---|
IItemQueue<TInput, TOutput> | TInput → TOutput | Base interface — Queue(TInput), Dequeue() → TOutput |
IItemQueue<TWorkItem> | T → T | Shorthand where input and output are the same type |
IBufferedItemQueue<TWorkItem> | T → T[] | Specialization for batched output |
| Scenario | Queue | Worker |
|---|---|---|
| Process items immediately, one by one | ItemQueue<T> | BackgroundQueueWorker<T> or hosted AbstractHostedServiceQueueWorker |
| Batch items for bulk operations | BufferedItemQueue<T> | BackgroundBufferedQueueWorker<T> |
| Batch items but don't wait forever for a full batch | ThrottledBufferedItemQueue<T> | BackgroundThrottledBufferedQueueWorker<T> or hosted worker |
| Long-running worker managed by ASP.NET host | Any queue subclass | AbstractHostedServiceQueueWorker |
| Short-lived fire-and-forget within a service | ItemQueue<T> (internal) | BackgroundQueueWorker<T> (creates its own queue) |
For standalone queue worker and hosted service queue worker examples, see examples/queue-workers.md.
/storm-api-redis) or an external message broker instead — in-memory queues are lost on shutdown.| ❌ Wrong | ✅ Correct |
|---|---|
Use ConcurrentQueue<T> or BlockingCollection<T> | Use ItemQueue<T> (channel-based, async-native) |
Poll the queue in a while loop with Task.Delay | Use Dequeue() which blocks efficiently via channels |
| Create queue workers without retry strategies for unreliable operations | Use DelayRetryStrategy or ExponentialBackOffStrategy |
| Register queue as transient/scoped | Register as singleton — producers and consumers must share the same instance |
Implement authentication using the Storm.Api framework with JWT, API key, custom authenticators, and refresh tokens. Use when adding auth to endpoints.
Write a database migration using the Storm.Api framework with BaseMigration and OrmLite. Use when creating or modifying database tables, columns, or seed data.
Implement database entities and repositories using the Storm.Api framework with ServiceStack.OrmLite. Use when creating entities, repositories, or database queries.
Implement email sending using the Storm.Api framework with Resend provider and temporary email detection. Use when sending emails or validating email addresses.
Implement a C# endpoint using the Storm.Api framework with CQRS actions, controllers, source generators, exceptions, and response DTOs.
Initialize a new Storm.Api project with NuGet packages, Program.cs, Startup.cs, and code style configuration. Use when setting up a new project from scratch.