AsyncFlow 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AsyncFlow --version 1.0.0
NuGet\Install-Package AsyncFlow -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AsyncFlow" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AsyncFlow --version 1.0.0
#r "nuget: AsyncFlow, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AsyncFlow as a Cake Addin
#addin nuget:?package=AsyncFlow&version=1.0.0

// Install AsyncFlow as a Cake Tool
#tool nuget:?package=AsyncFlow&version=1.0.0

AsyncFlow Library

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.

Features

  • Asynchronous Job Invocation: Easily handle long-running jobs by providing an immediate response with a job ID.
  • Status Tracking: Allow users to track the status of their job.
  • Flexible Result Retrieval: Once the job is complete, users can retrieve the result.
  • Integration with Hangfire: Make use of the robust background processing library, Hangfire, to handle job execution.
  • Extensible Cache Options: Store job results in-memory or use a distributed cache.

Getting Started

Installation

Use the package manager NuGet to install AsyncFlow:

dotnet add package AsyncFlow

Configuration

  1. Setup Hangfire (or any supported background job processor):

    builder.Services.AddHangfire(x => x.UseMemoryStorage());
    builder.Services.AddHangfireServer();
    
  2. Add AsyncFlow with Desired Cache:

    For in-memory cache:

    builder.Services.AddAsyncFlow(options => options.UseMemoryCache());
    

    For distributed cache:

    builder.Services.AddAsyncFlow(options => options.UseDistributedCache(yourDistributedCacheInstance));
    
  3. Map Endpoints:

    app.MapFlow<YourJobClass, YourRequestType, YourResponseType>("endpointName");
    

Custom Endpoint Configuration

You can customize the behavior of the AsyncFlow endpoints using the AsyncFlowEndpointConfigurator:

var configurator = new YourConfiguratorSubClass();
app.MapFlow<YourJobClass, YourRequestType, YourResponseType>("endpointName", configurator);

Usage Example

Define a job:

public class GenerateDataJob : IAsyncFlow<GenerateDataRequest, GenerateDataResponse>
{
    public async Task<GenerateDataResponse> ProcessAsync(GenerateDataRequest request)
    {
        // Your logic here
    }
}

Invoke it:

app.MapFlow<GenerateDataJob, GenerateDataRequest, GenerateDataResponse>("data");

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 235 11/28/2023
1.2.0 124 10/10/2023
1.1.0 4,012 8/20/2023
1.0.1 126 8/15/2023
1.0.0 120 8/15/2023