{"id":27612556,"url":"https://github.com/energy164/hompus.michiator","last_synced_at":"2025-04-23T01:45:08.319Z","repository":{"id":249686623,"uuid":"832238095","full_name":"eNeRGy164/Hompus.Michiator","owner":"eNeRGy164","description":"An Event Bus and Saga pattern, useful for.. me","archived":false,"fork":false,"pushed_at":"2024-07-22T16:04:47.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T05:05:28.739Z","etag":null,"topics":[],"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/eNeRGy164.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-07-22T15:44:35.000Z","updated_at":"2024-07-22T16:04:50.000Z","dependencies_parsed_at":"2024-07-22T19:41:34.063Z","dependency_job_id":null,"html_url":"https://github.com/eNeRGy164/Hompus.Michiator","commit_stats":null,"previous_names":["energy164/hompus.michiator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eNeRGy164%2FHompus.Michiator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eNeRGy164%2FHompus.Michiator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eNeRGy164%2FHompus.Michiator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eNeRGy164%2FHompus.Michiator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eNeRGy164","download_url":"https://codeload.github.com/eNeRGy164/Hompus.Michiator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250354295,"owners_count":21416749,"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":[],"created_at":"2025-04-23T01:45:07.846Z","updated_at":"2025-04-23T01:45:08.310Z","avatar_url":"https://github.com/eNeRGy164.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event-Driven Saga Orchestration\n\nThis project implements an event-driven architecture using a custom Event Dispatcher, Saga Orchestrator, and Event Bus Builder to handle events and manage long-running processes (sagas) in .NET.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Features](#features)\n- [Architecture](#architecture)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n- [Usage](#usage)\n- [Examples](#examples)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n## Introduction\n\nThis project demonstrates an event-driven architecture using the concepts of event dispatching, saga orchestration, and an event bus builder.\nThe solution is designed to handle events efficiently and manage long-running processes through sagas.\n\n## Features\n\n- **Event Dispatching**: Dispatches events to registered handlers.\n- **Saga Orchestration**: Manages the lifecycle of sagas based on events.\n- **Event Bus Builder**: Configures and builds the event handling infrastructure.\n- **Thread-Safe Collections**: Utilizes concurrent collections for thread safety.\n- **Detailed Logging**: Includes detailed logging for monitoring and debugging.\n\n## Architecture\n\n- **EventBus**: Handles publishing events and dispatching them to the appropriate handlers.\n- **SagaOrchestrator**: Manages the lifecycle and events for sagas.\n- **BusBuilder**: Helps in configuring and building the event handling infrastructure.\n\n## Getting Started\n\n### Prerequisites\n\n- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)\n\n### Installation\n\n1. Clone the repository:\n    ```sh\n    git clone https://github.com/eNeRGy164/Hompus.Michiator.git\n    cd Hompus.Michiator\n    ```\n\n2. Build the project:\n    ```sh\n    dotnet build\n    ```\n\n## Usage\n\n1. Register event handlers and sagas using the `BusBuilder`:\n    ```csharp\n    var host = Host.CreateDefaultBuilder(args)\n                .ConfigureServices((context, services) =\u003e\n                {\n                    services.AddLogging(configure =\u003e configure.AddConsole());\n\n                    var busBuilder = new BusBuilder()\n                        .RegisterHandlers(Assembly.GetExecutingAssembly())\n                        .RegisterSagas(Assembly.GetExecutingAssembly());\n\n                    services.AddEventBus(busBuilder);\n                })\n                .Build();\n\n    await host.RunAsync();\n    ```\n\n2. Define events, event handlers, and sagas:\n    ```csharp\n    public class CrosswordsSaga(ILogger\u003cCrosswordsSaga\u003e logger) : ISaga,\n        ISagaStartedBy\u003cPuzzleStarted\u003cCreditRoll\u003e\u003e,\n        IEventHandler\u003cNonNegativeFrameCaptured\u003e\n    {\n        private readonly ILogger logger = logger;\n\n        public CreditRollSaga(ILogger\u003cCreditRollSaga\u003e logger)\n        {\n            this.logger = logger;\n        }\n\n        public Task HandleStart(PuzzleStarted\u003cTPuzzle\u003e @event)\n        {\n            logger.LogInformation(\"CreditRollSaga started for event {EventType}\", @event.GetType());\n            // Your logic here\n            await Task.CompletedTask;\n        }\n\n        public async Task Handle(NonNegativeFrameCaptured @event)\n        {\n            logger.LogInformation(\"CreditRollSaga handling NonNegativeFrameCaptured event\");\n            // Your logic here\n            await Task.CompletedTask;\n        }\n\n        public void Reset()\n        {\n            logger.LogInformation(\"CreditRollSaga reset\");\n            // Your reset logic here\n        }\n    }\n    ```\n\n## Examples\n\n### Publishing an Event\n\n```csharp\npublic class ExampleEvent : IEvent\n{\n    public string Message { get; set; }\n}\n\n// Publishing an event\nvar eventBus = serviceProvider.GetRequiredService\u003cEventBus\u003e();\nawait eventBus.PublishAsync(new ExampleEvent { Message = \"Hello, World!\" });\n```\n\n### Handling an Event\n\n```csharp\npublic class ExampleEventHandler(ILogger\u003cExampleEventHandler\u003e logger) : IEventHandler\u003cExampleEvent\u003e\n{\n    public Task HandleAsync(ExampleEvent @event)\n    {\n        logger.LogInformation(\"Handled ExampleEvent: {Message}\", @event.Message);\n        return Task.CompletedTask;\n    }\n}\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.\n\n## Credits\n\nThis project was created with the help of [ChatGPT](https://openai.com/chatgpt) by OpenAI.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenergy164%2Fhompus.michiator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenergy164%2Fhompus.michiator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenergy164%2Fhompus.michiator/lists"}