Iwate.Commander 1.0.0-preview.1

This is a prerelease version of Iwate.Commander.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Iwate.Commander --version 1.0.0-preview.1                
NuGet\Install-Package Iwate.Commander -Version 1.0.0-preview.1                
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="Iwate.Commander" Version="1.0.0-preview.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Iwate.Commander --version 1.0.0-preview.1                
#r "nuget: Iwate.Commander, 1.0.0-preview.1"                
#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 Iwate.Commander as a Cake Addin
#addin nuget:?package=Iwate.Commander&version=1.0.0-preview.1&prerelease

// Install Iwate.Commander as a Cake Tool
#tool nuget:?package=Iwate.Commander&version=1.0.0-preview.1&prerelease                

NuGet version

A singleton lib for dotnet-isolated of Azure Functions

How to Install

$ dotnet add package Iwate.Commander

How to Use

public class Program
{
    public static async Task MainAsync(string[] args)
    {
        var services = new ServiceCollection();

        services.AddSingleton<IConfiguration>(new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string, string?>
        {
            ["AzureWebJobsStorage"] = "UseDevelopmentStorage=true",
        }).Build());

        services.AddLogging(builder =>
        {
            builder.AddConsole();
        });
        services.AddCommander(builder =>
        {
            builder
                .UseAzureBlobCommandStorage()
                //.UseInMemoryCommandStorage()
                .AddCommand<TestCommand>();
        });

        var provider = services.BuildServiceProvider();

        var commander = provider.GetRequiredService<Commander>();

        InvokeId id;
        using (var payload = new MemoryStream(JsonSerializer.SerializeToUtf8Bytes(new 
        { 
            Arg1 = 1,
            Arg2 = 2,
        })))
        {
            id = await commander.EnqueueAsync(null, nameof(TestCommand), payload, CancellationToken.None);
        }

        var state = await commander.GetStateAsync(id, CancellationToken.None);

        var request = await commander.PeekAsync(null, CancellationToken.None);

        state.Status = InvokeStatus.Processing;
        
        await commander.SetStateAsync(state, CancellationToken.None);

        try
        {
            await commander.InvokeAsync(request, CancellationToken.None);

            state.Status = InvokeStatus.Succeeded;
            await commander.SetStateAsync(state, CancellationToken.None);
            await commander.RemoveAsync(request, CancellationToken.None);
        }
        catch (Exception ex)
        {
            state.Status = InvokeStatus.Failed;
            await commander.SetStateAsync(state, CancellationToken.None);
            await commander.RemoveAsync(request, CancellationToken.None);
        }
    }
}
public class TestCommand : ICommand
{
    private readonly InvokeRequest _request;
    private readonly ILogger _logger;
    private readonly string _args;
    public TestCommand(InvokeRequest request, ILoggerFactory loggerFactory)
    {
        _request = request;
        _logger = loggerFactory.CreateLogger<TestCommand>();
        using var reader = new StreamReader(request.Payload);
        _args = reader.ReadToEnd();
    }
    
    public Task ExecuteAsync(CancellationToken cancellationToken)
    {
        _logger.LogInformation("{Id} {Command} {Args} Executing...", _request.Id, _request.Command, _args);

        return Task.CompletedTask;
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Iwate.Commander:

Package Downloads
Iwate.AzureFunctions.Middlewares.Commander

A command queuing library for Azure Functions

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-preview5 200 10/15/2023
1.0.0-preview4 65 10/15/2023
1.0.0-preview.6 60 10/30/2023
1.0.0-preview.3 114 12/21/2022
1.0.0-preview.2 108 12/14/2022
1.0.0-preview.1 108 12/13/2022