Tiger.Stripes.Instrumentation 1.0.0-rc8

This is a prerelease version of Tiger.Stripes.Instrumentation.
dotnet add package Tiger.Stripes.Instrumentation --version 1.0.0-rc8                
NuGet\Install-Package Tiger.Stripes.Instrumentation -Version 1.0.0-rc8                
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="Tiger.Stripes.Instrumentation" Version="1.0.0-rc8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tiger.Stripes.Instrumentation --version 1.0.0-rc8                
#r "nuget: Tiger.Stripes.Instrumentation, 1.0.0-rc8"                
#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 Tiger.Stripes.Instrumentation as a Cake Addin
#addin nuget:?package=Tiger.Stripes.Instrumentation&version=1.0.0-rc8&prerelease

// Install Tiger.Stripes.Instrumentation as a Cake Tool
#tool nuget:?package=Tiger.Stripes.Instrumentation&version=1.0.0-rc8&prerelease                

Tiger.Stripes

What It Is

Tiger.Stripes is a .NET library for simplifying the configuration and development of AWS Lambda Functions written in C# and compiled to NativeAOT. It provides a common host allowing for configuration and dependency injection nearly identical to that of ASP.NET Core.

Why You Want It

Even a non-complicated AWS Lambda Function can quickly gain a tedious amount of setup. An HttpClient requires a set of DelegatingHandlers, each of which requires its own set of dependencies, some of which are IOptions<TOptions>, and didn't Microsoft just release a library to simplify HttpClient?

Tiger.Lambda provides a host very similar to the WebApplicationHost of ASP.NET Core, allowing the application to be configured in all the ways familiar to an ASP.NET Core developer. The most common actions are exposed as overrideable methods on the Function handler. Even appsettings files are supported.

How To Use It

This library only targets .NET 8 and only targets AOT compilation. It simply will not work under the managed dotnet8 runtime. It must be deployed to a provided.* runtime.

The concept of a function handler is exposed by mapping a handler function to a name in the application builder. The following extremely simplified example illustrates a basic setup.

var builder = DownloaderApplication.CreateBuilder();

_ = builder.Services.AddSingleton(TimeProvider.System);
_ = builder.Services
    .AddSingleton<IValidateOptions<VendingMachineOptions>, VendingMachineOptions.Validator>()
    .AddOptions<VendingMachineOptions>()
    .BindConfiguration(VendingMachineOptions.VendingMachine);

await using var app = builder.Build();
_ = app.MapInvoke(
    "Vendor",
    static (object _, IAmazonS3 s3, TimeProvider time, IOptions<VendingMachineOptions> o) =>
    {
        var now = time.GetUtcNow();
        var req = new GetPreSignedUrlRequest
        {
            BucketName = o.Value.BucketName,
            Expires = now.Add(o.Value.CredentialsDuration).UtcDateTime,
            Key = Ulid.NewUlid(now).ToString("G", CI.InvariantCulture),
            Verb = HttpVerb.PUT,
        };
        return Results.Created(s3.GetPreSignedURL(req));
    },
    AwsContext.Default);

await app.RunAsync();

Invocations map a function handler to a name, and also provide the means to serialize input and deserialize outputs. This can be provided by a single instance of a type inheriting from JsonSerializerContext or by two instances of JsonTypeInfo<T>.

Thank You

Seriously, though. Thank you for using this software. The author hopes it performs admirably for you.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
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.0.0-rc8 35 11/18/2024

➟ Release 1.0.0
⁃ Everything is new!