{"id":28699618,"url":"https://github.com/litenova/LiteBus","last_synced_at":"2025-06-14T11:03:35.943Z","repository":{"id":43349175,"uuid":"318354851","full_name":"litenova/LiteBus","owner":"litenova","description":"LiteBus is an easy-to-use and ambitious in-process mediator providing the foundation to implement Command Query Separation (CQS). It is implemented with minimal reflection and instead utilizes covariance and contravariance to provide its core functionality.","archived":false,"fork":false,"pushed_at":"2025-06-09T13:42:12.000Z","size":821,"stargazers_count":105,"open_issues_count":1,"forks_count":9,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-10T07:16:44.516Z","etag":null,"topics":["cqrs","cqs","csharp","ddd-patterns","dotnet","dotnet-core","eventbus","mediator","mediator-pattern"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/litenova.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-04T00:14:35.000Z","updated_at":"2025-06-09T22:35:58.000Z","dependencies_parsed_at":"2023-02-09T21:50:21.721Z","dependency_job_id":"193aa44e-582a-405c-afd7-a0f089004285","html_url":"https://github.com/litenova/LiteBus","commit_stats":null,"previous_names":["arishk/paykan","arishk/litebus"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/litenova/LiteBus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FLiteBus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FLiteBus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FLiteBus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FLiteBus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/litenova","download_url":"https://codeload.github.com/litenova/LiteBus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litenova%2FLiteBus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259743002,"owners_count":22904642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cqrs","cqs","csharp","ddd-patterns","dotnet","dotnet-core","eventbus","mediator","mediator-pattern"],"created_at":"2025-06-14T11:01:27.619Z","updated_at":"2025-06-14T11:03:35.929Z","avatar_url":"https://github.com/litenova.png","language":"C#","funding_links":[],"categories":["Event aggregator and messenger"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003cbr\u003e\n\u003ca href=\"https://github.com/litenova/LiteBus\"\u003e\n\u003cimg src=\"assets/logo/icon.png\"\u003e\n\u003c/a\u003e\n\u003cbr\u003e\nLiteBus\n\u003cbr\u003e\n\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003eA lightweight, flexible in-process mediator for implementing Command Query Separation (CQS)\u003c/h4\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/litenova/LiteBus/actions/workflows/release.yml\"\u003e\n\u003cimg src=\"https://github.com/litenova/LiteBus/actions/workflows/release.yml/badge.svg\" alt=\"CI/CD Badge\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/litenova/LiteBus\" \u003e\n\u003cimg src=\"https://codecov.io/gh/litenova/LiteBus/graph/badge.svg?token=XBNYITSV5A\" alt=\"Code Coverage Badge\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.nuget.org/packages/LiteBus\"\u003e\n\u003cimg src=\"https://img.shields.io/nuget/vpre/LiteBus.svg\" alt=\"LiteBus Nuget Version\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\nFor detailed documentation and examples, please visit the \u003ca href=\"https://github.com/litenova/LiteBus/wiki\"\u003e\u003cb\u003eWiki\u003c/b\u003e\u003c/a\u003e.\n\u003c/p\u003e\n\n## Key Features\n\n- **Built in .NET 8**\n- **Zero external dependencies** - Completely standalone with no third-party dependencies\n- **Reduced reflection usage** - Optimized for performance with minimal reflection\n- **DDD-friendly design** - Support for plain domain events without library dependencies, keeping your domain model clean\n- **Comprehensive messaging types**:\n  - `ICommand` / `ICommand\u003cTResult\u003e` - For state-changing operations\n  - `IQuery\u003cTResult\u003e` - For data retrieval operations\n  - `IStreamQuery\u003cTResult\u003e` - For streaming large datasets via `IAsyncEnumerable\u003cT\u003e`\n  - `IEvent` - For notifications and event-driven architecture\n  - Support for POCO objects as messages without library interfaces\n\n- **Rich handler ecosystem**:\n  - Pre-handlers for validation and pre-processing\n  - Post-handlers for notifications and side effects\n  - Error handlers for centralized exception management\n  - Support for generic handlers and messages\n  - Handler ordering control\n  - Contextual handler selection via tags and filters\n\n- **Advanced features**:\n  - Covariant type handling for polymorphic dispatch\n  - Execution context for cross-cutting concerns\n  - Aborting execution flow when needed\n  - Microsoft Dependency Injection integration\n\n## Quick Example\n\n```csharp\n// Define the command result\npublic record CreateProductCommandResult(Guid Id);\n\n// Define a command with a result\npublic record CreateProductCommand(string Title) : ICommand\u003cCreateProductCommandResult\u003e;\n\n// Implement a command validator\npublic class CreateProductCommandValidator : ICommandValidator\u003cCreateProductCommand\u003e\n{\n    public Task ValidateAsync(CreateProductCommand command, CancellationToken cancellationToken = default)\n    {\n        if (string.IsNullOrWhiteSpace(command.Title))\n            throw new ValidationException(\"Product title cannot be empty\");\n            \n        return Task.CompletedTask;\n    }\n}\n\n// Implement a command handler\npublic class CreateProductCommandHandler : ICommandHandler\u003cCreateProductCommand, CreateProductCommandResult\u003e\n{\n    private readonly IProductRepository _repository;\n    \n    public CreateProductCommandHandler(IProductRepository repository)\n    {\n        _repository = repository;\n    }\n    \n    public async Task\u003cCreateProductCommandResult\u003e HandleAsync(CreateProductCommand command, CancellationToken cancellationToken = default)\n    {\n        var product = new Product(Guid.NewGuid(), command.Title);\n        \n        await _repository.SaveAsync(product, cancellationToken);\n        \n        return new CreateProductCommandResult(product.Id);\n    }\n}\n\n// Configure in ASP.NET Core\nservices.AddLiteBus(liteBus =\u003e\n{\n    liteBus.AddCommandModule(module =\u003e\n    {\n        module.RegisterFromAssembly(typeof(CreateProductCommand).Assembly);\n    });\n});\n\n// Use in a controller or service\npublic class ProductsController : ControllerBase\n{\n    private readonly ICommandMediator _commandMediator;\n    \n    public ProductsController(ICommandMediator commandMediator)\n    {\n        _commandMediator = commandMediator;\n    }\n    \n    [HttpPost]\n    public async Task\u003cActionResult\u003cCreateProductCommandResult\u003e\u003e CreateProduct(CreateProductCommand command)\n    {\n        var result = await _commandMediator.SendAsync(command);\n        return Ok(result);\n    }\n}\n```\n\n## Documentation\n\nFor comprehensive documentation, including detailed explanations, advanced features, and best practices, please visit the [Wiki](https://github.com/litenova/LiteBus/wiki).\n\n## Installation\n\nLiteBus is available as NuGet packages:\n\n```\ndotnet add package LiteBus\ndotnet add package LiteBus.Extensions.MicrosoftDependencyInjection\n```\n\nOr specific modules:\n\n```\ndotnet add package LiteBus.Commands\ndotnet add package LiteBus.Queries\ndotnet add package LiteBus.Events\n```\n\n## License\n\nLiteBus is licensed under the MIT License. See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitenova%2FLiteBus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitenova%2FLiteBus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitenova%2FLiteBus/lists"}