Buzzard is a lightweight, fast, and extensible .NET library that implements the Mediator pattern — similar to MediatR — with full developer control and minimal overhead.
- Request/Response messaging with
IRequest<TResponse> - Fire-and-forget notifications with
INotification - Clean, dependency-injection-first design
- No runtime reflection or complex setup
- Designed for performance and testability
Install via NuGet:
dotnet add package BuzzardRegister Buzzard in your Startup.cs or Program.cs:
services.AddBuzzard();public class GetUserQuery : IRequest<User>
{
public int Id { get; set; }
}public class GetUserQueryHandler : IHandler<GetUserQuery, User>
{
public Task<User> HandleAsync(GetUserQuery request, CancellationToken cancellationToken)
{
// Fetch from database or service
return Task.FromResult(new User { Id = request.Id, Name = "Alice" });
}
}var user = await _buzzardMediator.SendAsync(new GetUserQuery { Id = 1 });Buzzard supports fire-and-forget notifications that can have multiple handlers.
public class OrderPlaced : INotification
{
public int OrderId { get; set; }
}public class EmailHandler : INotificationHandler<OrderPlaced>
{
public Task HandleAsync(OrderPlaced notification, CancellationToken cancellationToken)
{
// Send confirmation email
return Task.CompletedTask;
}
}public class LogHandler : INotificationHandler<OrderPlaced>
{
public Task HandleAsync(OrderPlaced notification, CancellationToken cancellationToken)
{
// Log the order
return Task.CompletedTask;
}
}await _buzzardMediator.PublishAsync(new OrderPlaced { OrderId = 123 });Optionally choose the publish strategy:
await _buzzardMediator.PublishAsync(notification, PublishStrategy.Parallel); // Background threads
await _buzzardMediator.PublishAsync(notification, PublishStrategy.ParallelWhenAll); // Waits for all
await _buzzardMediator.PublishAsync(notification, PublishStrategy.Sequential); // DefaultBuzzard makes testing easy. You can test handlers directly:
var handler = new GetUserQueryHandler();
var result = await handler.HandleAsync(new GetUserQuery { Id = 1 }, CancellationToken.None);Or mock IBuzzardMediator for higher-level tests.
Contributions are welcome! Feel free to open an issue or submit a pull request if you want to help improve Buzzard.
Buzzard is licensed under the MIT License.
