Pseudonym.Net.Library.Lambda.Core 1.0.9

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

// Install Pseudonym.Net.Library.Lambda.Core as a Cake Tool
#tool nuget:?package=Pseudonym.Net.Library.Lambda.Core&version=1.0.9

Pseudonym.Net.Library.Lambda.Core

This is a Library to streamline Lambda under one common operation or standard. It is geared towards those who are used to developing with .netcore and familiar with the concepts of dependency injection and component based architecture.

This library wraps Amazon.Lambda.Core and provides the following benefits:

  • No Lambda Handlers to have to configure, as the library contains the lambda raw entrypoint and self discovers an entrypoint you define through interfaces.
  • Scoped Dependency Injection through the use of discoverable interfaces to configure your container.
  • Wrapping of logging, ILambdaContext and other Amazon features to make them injectable.
  • Integrated Error handling to log out and return¹ an errors encountered.
  • Simple, fast and easy - one class lambda with all the mess sorted for you.

Configuring the entry point

To configure the entry point using this library, you simple need to inherit the ISyncLambdaRequestProcessor interface or the IAsyncLambdaRequestProcessor interface if you're creating an async lambda².

The generic TInput can be the class model representative of the json you intend to pass to the lambda, this will be automatically detected and parsed into this type upon running. If your lambda is a sync lambda, you can also specify a TOutput generic type which will be wrapped by IlambdaReponse.

When configuring the lambda, the handler string will always be the same:

  • Sync: Pseudonym.Net.Library.Lambda.Core.Implementation::Implementation.SyncLambdaRequestProcessor::ExecuteAsync
  • Async: Pseudonym.Net.Library.Lambda.Core.Implementation::Implementation.AsyncLambdaRequestProcessor::ExecuteAsync

Note: you can only have one implementation of one of these interfaces in your solution, if not you'll receive a runtime error.

Registering Services to the Container

Once you have made your entry point, you'll need to register it to the container, along with any other services you need to. This is done by creating a class that inherits the IContainerServicesSetup interface. There, you will have access to the container, where you can register the entry point by calling container.AddSyncHandler()/container.AddAsyncHandler().

You can also register additional services as normal, as per the example below:

public class ContainerConfig : IContainerServicesSetup
{
    public void Configure(IServiceCollection container)
    {
        //registering a Sync handler that takes an integer and responds with a string.
        container.AddSyncHandler<int, string, SyncHandler>();

        container.AddScoped<ScopedLambdaContext>()
            .AddTransient<ILambdaContext>(sp => sp.GetRequiredService<ScopedLambdaContext>().Context)
            .AddTransient<IScopedLambdaContextSetter>(sp => sp.GetRequiredService<ScopedLambdaContext>());

        container.AddTransient<ILambdaSerializer>(sp => sp.GetRequiredService<JsonSerializer>());
    }
}

Available helper classes

  • You can resolve amazons ILambdaContext from anywhere in the code by injecting it into the constructor of your class, this is all made injectable behind the scenes.
  • You can resolve ILambdaResponder with a generic payload from anywhere in the code to get a wrapped helper that will build response objects for you.
  • You can resolve ILambdaSerializer from anywhere in the code to get hold of the current lambdas serializer and its settings.

Footnotes

¹ Footnote content goes here Will only return the error if the compiled json of the error is under 6MB as that is the restriction on lambdas.

² Note, that in terms of async and sync lambdas an Sync lambda is when you essentially have a blocking lambda that returns a result, whereas an Async Lambda just runs, and does not return a result. Both Async & Sync lambdas are run in a async context in terms of .net async from System.Threading.Tasks, please don't confuse these!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 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.4.1 584 10/22/2019
1.4.0 465 10/22/2019
1.3.3 476 10/21/2019
1.3.2 487 10/21/2019
1.3.1 466 10/21/2019
1.3.0 456 10/21/2019
1.2.2 493 10/14/2019
1.2.1 615 10/14/2019
1.2.0 496 10/14/2019
1.1.2 468 10/11/2019
1.1.1 608 10/11/2019
1.1.0 622 10/11/2019
1.0.9 639 10/11/2019
1.0.8 542 10/11/2019
1.0.7 553 10/11/2019
1.0.6 530 10/11/2019
1.0.5 541 10/11/2019
1.0.4 537 10/11/2019
1.0.3 525 10/11/2019
1.0.2 545 10/11/2019
1.0.1 516 10/11/2019
1.0.0 540 10/11/2019