Tiger.Stripes
1.0.0-rc1
See the version list below for details.
dotnet add package Tiger.Stripes --version 1.0.0-rc1
NuGet\Install-Package Tiger.Stripes -Version 1.0.0-rc1
<PackageReference Include="Tiger.Stripes" Version="1.0.0-rc1" />
paket add Tiger.Stripes --version 1.0.0-rc1
#r "nuget: Tiger.Stripes, 1.0.0-rc1"
// Install Tiger.Stripes as a Cake Addin #addin nuget:?package=Tiger.Stripes&version=1.0.0-rc1&prerelease // Install Tiger.Stripes as a Cake Tool #tool nuget:?package=Tiger.Stripes&version=1.0.0-rc1&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 DelegatingHandler
s,
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- Amazon.Lambda.RuntimeSupport (>= 1.10.0)
- CommunityToolkit.HighPerformance (>= 8.2.2)
- Microsoft.Extensions.Hosting (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
➟ Release 1.0.0
⁃ Everything is new!