{"id":23514454,"url":"https://github.com/TheFo2sh/AsyncFlow","last_synced_at":"2025-08-28T08:31:21.720Z","repository":{"id":188363572,"uuid":"678619525","full_name":"TheFo2sh/AsyncFlow","owner":"TheFo2sh","description":"Integrate asynchronous job flows with ease in your .NET applications. AsyncFlow is designed for web applications that use a pattern where users call an invoke API, receive a job ID, and can then track and retrieve the job's results using separate endpoints.","archived":false,"fork":false,"pushed_at":"2023-11-28T02:53:23.000Z","size":72,"stargazers_count":46,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-20T15:48:21.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/TheFo2sh.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-15T01:20:27.000Z","updated_at":"2024-12-09T21:52:47.000Z","dependencies_parsed_at":"2023-08-15T02:34:45.700Z","dependency_job_id":null,"html_url":"https://github.com/TheFo2sh/AsyncFlow","commit_stats":null,"previous_names":["thefo2sh/asyncflow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFo2sh%2FAsyncFlow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFo2sh%2FAsyncFlow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFo2sh%2FAsyncFlow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFo2sh%2FAsyncFlow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheFo2sh","download_url":"https://codeload.github.com/TheFo2sh/AsyncFlow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231242753,"owners_count":18346600,"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":"2024-12-25T14:01:44.817Z","updated_at":"2024-12-25T14:02:06.000Z","avatar_url":"https://github.com/TheFo2sh.png","language":"C#","funding_links":[],"categories":["Contributors Welcome for those"],"sub_categories":["1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category"],"readme":"﻿# AsyncFlow Library\n\nIntegrate asynchronous job flows with ease in your .NET applications. AsyncFlow is designed for web applications that use a pattern where users call an invoke API, receive a job ID, and can then track and retrieve the job's results using separate endpoints.\n\n## Features\n\n- **Asynchronous Job Invocation**: Easily handle long-running jobs by providing an immediate response with a job ID.\n- **Status Tracking**: Allow users to track the status of their job.\n- **Flexible Result Retrieval**: Once the job is complete, users can retrieve the result.\n- **Integration with Hangfire**: Make use of the robust background processing library, Hangfire, to handle job execution.\n- **Extensible Cache Options**: Store job results in-memory or use a distributed cache.\n\n## Getting Started\n\n### Installation\n\nUse the package manager [NuGet](https://www.nuget.org/packages/AsyncFlow/) to install AsyncFlow packages:\n\n```bash\ndotnet add package AsyncFlow\ndotnet add package AsyncFlow.Queues.Generator\n```\n\n### Configuration\n\n1. **Setup Hangfire (or any supported background job processor)**:\n\n   ```csharp\n   builder.Services.AddHangfire(x =\u003e x.UseMemoryStorage());\n   builder.Services.AddHangfireServer(options =\u003e options.Queues = Flows.All));\n   ```\n\n2. **Add AsyncFlow with Desired Cache**:\n\n   For in-memory cache:\n\n   ```csharp\n   builder.Services.AddAsyncFlow(options =\u003e options.UseMemoryCache());\n   ```\n\n   For distributed cache:\n\n   ```csharp\n   builder.Services.AddAsyncFlow(options =\u003e options.UseDistributedCache(yourDistributedCacheInstance));\n   ```\n\n3. **Map Endpoints**:\n\n   ```csharp\n   app.MapFlow\u003cYourJobClass, YourRequestType, YourResponseType\u003e(\"endpointName\");\n   ```\nCertainly! Let's replace the C# record descriptions with JSON examples for the responses:\n\n## The Auto created API Endpoints\n\nWhen you integrate the `AsyncFlow` library into your application, the following API endpoints are provided for you:\n\n1. **Enqueue Endpoint**:\n\n   - **Path**: `/[flowName]`\n   - **HTTP Method**: POST\n   - **Purpose**: To initiate the async flow process.\n   - **Response**:\n     ```json\n     {\n       \"RequestId\": \"12345-abcd\",\n       \"DateTime\": \"2023-08-14T15:30:45Z\"\n     }\n     ```\n\n2. **Status Endpoint**:\n\n   - **Path**: `/[flowName]/{jobId}/status`\n   - **HTTP Method**: GET\n   - **Purpose**: To check the status of a previously enqueued request.\n     - **Response**:\n       ```json\n       {\n         \"RequestId\": \"12345-abcd\",\n         \"Status\": \"Processing\",\n         \"CreatedAt\": \"2023-08-14T15:30:45Z\",\n         \"progressData\": {\n             \"progress\": \"Generating Data\",\n             \"percentage\": 90\n         }\n       }\n       ```\n3. **Result Endpoint**:\n\n   - **Path**: `/[flowName]/{jobId}/result`\n   - **HTTP Method**: GET\n   - **Purpose**: To retrieve the result of the job.\n   - **Response**: JSON that represents the result object.\n\n4. **Delete Endpoint**:\n\n   - **Path**: `/[flowName]/{jobId}`\n   - **HTTP Method**: DELETE\n   - **Purpose**: To delete the result of the job.\n   - **Response**: No content (empty response).\n\n5. **Error Endpoint**:\n\n- **Path**: /[flowName]/{jobId}/error\n- **HTTP Method**: GET\n- **Purpose**: To retrieve error details if a job fails.\n- **Response**:\n```json{\n  \"JobId\": \"unique-job-id\",\n  \"Error\": {\n  \"Type\": \"ExceptionType\",\n  \"Message\": \"Detailed error message\",\n  \"StackTrace\": \"Stack trace details...\"\n     }\n  }\n ```\n---\n\nRemember to replace the placeholders like \"*Details about the Result endpoint, including a JSON example.*\" with the actual details for those endpoints if they provide responses similar to the ones you've described. If not, describe them as needed.\n\nAlso, make sure to guide your users on how to replace the `[flowName]` placeholder appropriately.\n### Custom Endpoint Configuration\n\nYou can customize the behavior of the AsyncFlow endpoints using the `AsyncFlowEndpointConfigurator`:\n\n```csharp\nvar configurator = new YourConfiguratorSubClass();\napp.MapFlow\u003cYourJobClass, YourRequestType, YourResponseType\u003e(\"endpointName\", configurator);\n```\n\n## Usage Example\n\nDefine a job:\n\n```csharp\npublic class GenerateDataJob : IAsyncFlow\u003cGenerateDataRequest, GenerateDataResponse\u003e\n{\n    public async Task\u003cGenerateDataResponse\u003e ProcessAsync(GenerateDataRequest request ,IProgress\u003cProgressData\u003e progress , CancellationToken cancellationToken)\n    {\n        // Your logic here\n    }\n}\n```\n\nInvoke it:\n\n```csharp\napp.MapFlow\u003cGenerateDataJob, GenerateDataRequest, GenerateDataResponse\u003e(\"data\");\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nThis project is licensed under the MIT License.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheFo2sh%2FAsyncFlow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTheFo2sh%2FAsyncFlow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheFo2sh%2FAsyncFlow/lists"}