CQRSharp 2.2.6
dotnet add package CQRSharp --version 2.2.6
NuGet\Install-Package CQRSharp -Version 2.2.6
<PackageReference Include="CQRSharp" Version="2.2.6" />
<PackageVersion Include="CQRSharp" Version="2.2.6" />
<PackageReference Include="CQRSharp" />
paket add CQRSharp --version 2.2.6
#r "nuget: CQRSharp, 2.2.6"
#addin nuget:?package=CQRSharp&version=2.2.6
#tool nuget:?package=CQRSharp&version=2.2.6
CQRSharp
A lightweight, extensible, and attribute-driven Command Query Responsibility Segregation (CQRS) framework for .NET applications, with complete Native AoT support.
For more information, please advise the wiki page!
Contributing
Contributions are welcome! Please open issues and pull requests for bug fixes, enhancements, or new features.
To contribute:
- Fork the repository.
- Create a new branch.
- Make your changes.
- Submit a pull request.
Please ensure that your code follows the project's coding standards and includes appropriate tests.
License
This project is licensed under the MIT License.
Note: This project is in active development.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. |
-
net10.0
- CQRSharp.Shared (>= 2.2.6)
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Hosting (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
- Microsoft.Extensions.Logging.Console (>= 9.0.2)
-
net8.0
- CQRSharp.Shared (>= 2.2.6)
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Hosting (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
- Microsoft.Extensions.Logging.Console (>= 9.0.2)
-
net9.0
- CQRSharp.Shared (>= 2.2.6)
- Microsoft.Extensions.DependencyInjection (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Hosting (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
- Microsoft.Extensions.Logging.Console (>= 9.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
2.2.6 | 157 | 4/20/2025 | |
2.2.5 | 123 | 4/11/2025 | |
2.2.4 | 166 | 4/7/2025 | |
2.2.3.1 | 265 | 3/11/2025 | |
2.2.3 | 248 | 3/10/2025 | |
2.2.2 | 292 | 3/8/2025 | |
2.2.0 | 208 | 2/8/2025 | |
2.1.0 | 174 | 1/8/2025 | |
2.0.0 | 196 | 1/2/2025 | |
1.1.6 | 204 | 12/5/2024 | |
1.1.5 | 202 | 10/24/2024 | |
1.1.4 | 207 | 10/11/2024 | |
1.1.3 | 196 | 9/28/2024 | |
1.1.2 | 202 | 9/28/2024 | |
1.1.1 | 200 | 9/24/2024 | |
1.1.0 | 203 | 9/23/2024 | |
1.0.0 | 212 | 9/23/2024 |
Version 2.2.6 (2025‑04‑20)
Breaking Changes
- `QueueBackgroundWorkItemAsync` now returns `Task<QueueWriteResult>` instead of a fire‑and‑forget `Task`.
- `IBackgroundTaskQueue` no longer exposes `OnTaskEnqueued`/`OnTaskRejected` events; use the notification channel.
- `BackgroundTaskQueue.DequeueAsync` signature changed to `ValueTask<QueuedTask>`.
- `BackgroundTaskQueueOptions.DequeueBatchSize` deprecated in favor of `CallbackChannelCapacity` and `ShutdownTimeout`.
- All `.ContinueWith` usage in the Dispatcher was replaced by `async`/`await`, preserving stack traces and the `SynchronizationContext`.
Added
- **Dispatcher**: `EnqueueAndWatchAsync` helper; simplified `finalHandlerWrapper` logic.
- **DI Extensions**: `CqrsStartupLogger` (`IHostedService`) & `CqrsRegistrationInfo` for deferred CQRS‑registration logging.
- **RateLimiter**: `ShardedLruCache` with per‑shard LRU eviction; implements `IDisposable` to tear down the cleanup timer.
- **BackgroundTaskQueue**:
- `QueuedTask` struct (with `QueueId`, `SequenceNumber`, `EnqueueTime`) and `QueueWriteResult` struct.
- Built‑in metrics: `TotalItemsEnqueued`, `TotalDroppedNewest`, `TotalDroppedOldest`.
- Dedicated notification channel via `INotificationDispatcher`.
- `CountingChannelReader` for atomic queue‑depth tracking.
- **BackgroundTaskQueueConsumer**: single loop gated by a `SemaphoreSlim` (`ConsumerCount`); lifecycle logging; `ShutdownTimeout` support.
Changed
- **Dispatcher**: `ExecuteCommand` now returns a `Task` immediately in async mode.
- **RateLimiter**:
- Corrected refill formula to apply `replenishRatePerSecond` directly.
- High‑precision timing via `Stopwatch.GetTimestamp()`.
- Sliding‑expiration cleanup via explicit snapshot and background timer.
- **BackgroundTaskQueue**:
- Consolidated multi‑shard design into a single bounded `Channel<QueuedTask>`.
- Explicit implementation of all `BoundedChannelFullMode` policies (`Wait`, `DropNewest`, `DropOldest`, `Throw`).
- Replaced manual `WaitToReadAsync` and`TryRead` loops with `ReadAllAsync()`.
- Refactored notification dispatch into `ProcessNotificationsAsync` with retry parameters.
Removed
- All `.ContinueWith` calls; static CQRS‑registrar logging at DI setup.
- Third‑party/`MemoryCache` dependencies in `RateLimiter`.
- Busy‑wait loops and redundant `Task.Run` calls in the background queue.
- Public `OnTaskEnqueued`/`OnTaskRejected` events on `IBackgroundTaskQueue`.
Fixed
- Race conditions in `DropOldest`/`DropNewest` policies under contention.
- Cancellation and exception propagation in `Dispatcher.EnqueueAndWatchAsync`.
- Timer leak in `RateLimiter` by implementing `Dispose`.
- Refill‑rate drift in token‑bucket logic; restored full exception stacks by removing `.ContinueWith`.
Performance
- **Dispatcher**: end‑to‑end `await` for context‑safe execution.
- **RateLimiter**: sharded cache + stopwatch timing for minimal contention.
- **BackgroundTaskQueue**: single channel + `CountingChannelReader` for lock‑free depth tracking.
- **Consumer**: `SemaphoreSlim`‑gated loop avoids thread‑pool storms.
Testing
- **DispatcherTests**: sync/async execution, cancellation, exception‑propagation coverage.
- **RateLimiterTests**: refill accuracy, shard eviction, timer disposal.
- **BackgroundTaskQueueTests**: backpressure modes, FIFO ordering, metrics, high‑concurrency and graceful shutdown.
- **RequestDispatcherTests**: host‑lifetime cancellation via `TestHostApplicationLifetime`.
- **BackgroundTaskQueueConsumerTests**: concurrency gating and lifecycle logging.
Documentation
- Updated XML docs for new options (`EnableMetrics`, `NotificationMaxRetries`, `ShutdownTimeout`, `MetricLogInterval`).
- Clarified defaults and valid ranges in `BackgroundTaskQueueOptions` and `RateLimiterOptions`.