{"id":31028295,"url":"https://github.com/zeidlab/eventbuss","last_synced_at":"2026-01-20T16:57:05.311Z","repository":{"id":307040771,"uuid":"1000932435","full_name":"ZeidLab/EventBuss","owner":"ZeidLab","description":"EventBuss is a lightweight, high-performance in-process messaging library for .NET. It simplifies the mediator pattern with System.Threading.Channels for fast event publishing and handling. As a simpler MediatR alternative, it cleanly supports CQRS and event-driven designs without complex pipelines.","archived":false,"fork":false,"pushed_at":"2025-06-27T17:03:28.000Z","size":194,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-29T05:51:47.446Z","etag":null,"topics":["channels","cqrs","event-driven","event-handling","events","in-process-messaging","messaging","request-response","request-response-processing"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZeidLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2025-06-12T14:42:26.000Z","updated_at":"2025-06-27T17:56:12.000Z","dependencies_parsed_at":"2025-07-29T06:03:36.329Z","dependency_job_id":null,"html_url":"https://github.com/ZeidLab/EventBuss","commit_stats":null,"previous_names":["zeidlab/eventbuss"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ZeidLab/EventBuss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeidLab%2FEventBuss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeidLab%2FEventBuss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeidLab%2FEventBuss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeidLab%2FEventBuss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZeidLab","download_url":"https://codeload.github.com/ZeidLab/EventBuss/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeidLab%2FEventBuss/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275020168,"owners_count":25391652,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["channels","cqrs","event-driven","event-handling","events","in-process-messaging","messaging","request-response","request-response-processing"],"created_at":"2025-09-13T20:13:17.113Z","updated_at":"2026-01-20T16:57:05.286Z","avatar_url":"https://github.com/ZeidLab.png","language":"C#","readme":"﻿# ZeidLab.ToolBox.EventBuss\n\n## 🤔 What is `ZeidLab.ToolBox.EventBuss` Library?\n\n**ZeidLab.ToolBox.EventBuss** is a lightweight, high-performance in-process event handling and messaging library for .NET applications. It provides a clean and efficient way to implement event-driven architectures, enabling loose coupling between components through a publisher-subscriber model. The library supports both event publishing (fire-and-forget) and request-response patterns, making it versatile for various communication needs within your application.\n\n### 🎁 Features\n\n* **Event Publishing:** Fire-and-forget event publishing with automatic handler discovery and invocation\n* **Request Handling:** Send requests and optionally receive responses using a clean, typed interface\n* **Automatic Registration:** Scan assemblies to automatically discover and register event and request handlers\n* **High-Performance:** Optimized for minimal overhead and maximum throughput in critical paths\n* **Background Processing:** Events are processed asynchronously in a background service\n* **Parallel Execution:** Configurable parallel processing of events for improved throughput\n* **Dependency Injection:** Seamless integration with Microsoft's dependency injection system\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n\n## 📦 Installation\n\nTo use **ZeidLab.ToolBox.EventBuss** in your project, you can install it via NuGet:\n\n```bash\ndotnet add package ZeidLab.ToolBox.EventBuss\n```\n\nFor more information, please visit [EventBuss Package on NuGet](https://www.nuget.org/packages/ZeidLab.ToolBox.EventBuss).\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n\n## 📝 ChangeLogs\n\nWith each release, we add new features and fix bugs. You can find the full changelog at [EventBuss Releases](https://github.com/ZeidLab/EventBuss/releases).\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n\n## 📖 Usage and Configuration\n\nEventBuss provides a straightforward API for event publishing and request handling in your .NET applications.\n\n### Basic Configuration\n\nRegister EventBuss in your application's service collection during startup:\n\n```csharp\n// Add with default configuration\nbuilder.Services.AddEventBuss();\n\n// Or with custom configuration\nbuilder.Services.AddEventBuss(options =\u003e\n{\n    // Register handlers from specific assemblies\n    options.RegisterFromAssembly(typeof(Program).Assembly);\n    \n    // Discover handlers from referenced assemblies\n    options.FromDependencies = true;\n    \n    // Configure parallel processing (optional)\n    // The default value is the number of available processors cores\n    // One thread per core is recommended for optimal performance\n    options.MaxDegreeOfParallelism = 4;\n});\n```\n\n### Publishing Events\n\nCreate event object by implementing the `IAppEvent` interface. It can be a simple record or class, however we recommend you to use a `readonly` type for optimized performance. In this example it is a `readonly record struct` . Then, use the `IEventBussService` to publish events:\n\n```csharp\n// Define an event\npublic readonly record struct UserCreatedEvent(string UserId, string Username) : IAppEvent;\n\n// Publish an event\n_eventBussService.Publish(new UserCreatedEvent(\"user123\", \"johndoe\"));\n```\n\n### Creating Event Handlers\n\nImplement the `IAppEventHandler\u003cT\u003e` interface to handle specific events:\n\n```csharp\npublic class UserCreatedEventHandler : IAppEventHandler\u003cUserCreatedEvent\u003e\n{\n    private readonly ILogger\u003cUserCreatedEventHandler\u003e _logger;\n    \n    public UserCreatedEventHandler(ILogger\u003cUserCreatedEventHandler\u003e logger)\n    {\n        _logger = logger;\n    }\n    \n    public async Task HandleAsync(UserCreatedEvent @event, CancellationToken cancellationToken)\n    {\n        _logger.LogInformation(\"User created: {UserId}, {Username}\", @event.UserId, @event.Username);\n        await Task.CompletedTask;\n    }\n}\n```\n\n### Sending Requests\n\nSend requests and receive responses using the request-response pattern. The request can be a simple record or class, however we recommend you to use a `readonly` type for optimized performance. In this example it is a `readonly record struct` :\n\n```csharp\n// Define a request and handler\npublic readonly record struct GetUserRequest(string UserId) : IRequest\u003cUserDetails\u003e;\n\npublic class GetUserRequestHandler : IRequestHandler\u003cGetUserRequest, UserDetails\u003e\n{\n    private readonly IUserRepository _repository;\n    \n    public GetUserRequestHandler(IUserRepository repository)\n    {\n        _repository = repository;\n    }\n    \n    public async Task\u003cUserDetails\u003e HandleAsync(GetUserRequest request, CancellationToken cancellationToken)\n    {\n        return await _repository.GetUserByIdAsync(request.UserId, cancellationToken);\n    }\n}\n\n// Send the request and get a response\nvar userDetails = await _eventBussService.SendAsync\u003cGetUserRequest, UserDetails\u003e(\n    new GetUserRequest(\"user123\"), \n    cancellationToken\n);\n```\n\n### Core Components\n\n| Component                             | Description                                                  |\n|---------------------------------------|--------------------------------------------------------------|\n| `IEventBussService`                   | Core service for publishing events and sending requests      |\n| `IAppEvent`                           | Marker interface for event objects                           |\n| `IAppEventHandler\u003cT\u003e`                 | Interface for event handlers                                 |\n| `IRequest\u003cTResponse\u003e`                 | Interface for request objects that expect a response         |\n| `IRequest`                            | Interface for request objects that don't expect a response   |\n| `IRequestHandler\u003cTRequest,TResponse\u003e` | Interface for request handlers that return a response        |\n| `IRequestHandler\u003cTRequest\u003e`           | Interface for request handlers that do not return a response |\n| `EventBussOptions`                    | Configuration options for EventBuss                          |\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n\n## ⭐️ Star and Follow\n\nStar this repository and follow me on GitHub to stay informed about new releases and updates. Your support fuels this\nproject's growth!\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n\n## 💡 Love My Work? Support the Journey!\n\nIf my content adds value to your projects, consider supporting me via crypto.\n\n- **Bitcoin:** bc1qlfljm9mysdtu064z5cf4yq4ddxgdfztgvghw3w\n- **USDT(TRC20):** TJFME9tAnwdnhmqGHDDG5yCs617kyQDV39\n\nThank you for being part of this community—let’s build smarter, together\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n\n## 🤝 Contributions\n\nContributions are welcome! Please feel free to submit issues, feature requests, or pull requests.\n\n1. Fork the repository\n2. Create a new branch for your feature or bugfix\n3. Commit your changes following the project guidelines\n4. Push your branch and submit a pull request\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE.txt) file for details.\n\n[^ Back To Top](#-what-is-zeidlabtoolboxeventbuss-library)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeidlab%2Feventbuss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeidlab%2Feventbuss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeidlab%2Feventbuss/lists"}