MinimalLambda.Abstractions 2.0.0-beta.11

This is a prerelease version of MinimalLambda.Abstractions.
dotnet add package MinimalLambda.Abstractions --version 2.0.0-beta.11
                    
NuGet\Install-Package MinimalLambda.Abstractions -Version 2.0.0-beta.11
                    
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="MinimalLambda.Abstractions" Version="2.0.0-beta.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MinimalLambda.Abstractions" Version="2.0.0-beta.11" />
                    
Directory.Packages.props
<PackageReference Include="MinimalLambda.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MinimalLambda.Abstractions --version 2.0.0-beta.11
                    
#r "nuget: MinimalLambda.Abstractions, 2.0.0-beta.11"
                    
#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.
#:package MinimalLambda.Abstractions@2.0.0-beta.11
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MinimalLambda.Abstractions&version=2.0.0-beta.11&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MinimalLambda.Abstractions&version=2.0.0-beta.11&prerelease
                    
Install as a Cake Tool

MinimalLambda.Abstractions

Core interfaces and abstractions for the minimal-lambda framework.

📚 View Full Documentation

Overview

Core interfaces and delegates that define the MinimalLambda framework contract. This package provides:

  • Handler Abstractions: Interfaces for Lambda request and response handling across different event types
  • Envelope Abstractions: Contracts for extracting request payloads and packing response payloads
  • Middleware Contracts: Abstractions for building and composing middleware components
  • Dependency Injection: Service container and lifetime management interfaces
  • Extension Points: Contracts for custom integrations and framework extensions

This package is typically used implicitly by MinimalLambda, but is essential if you're building custom integrations, middleware components, or extensions to the framework.

Installation

Install via NuGet:

dotnet add package MinimalLambda.Abstractions

Or specify a version:

dotnet add package MinimalLambda.Abstractions --version <version>

Ensure your project uses C# 11 or later:


<PropertyGroup>
  <LangVersion>11</LangVersion>
  
</PropertyGroup>

This package is typically included automatically when you use MinimalLambda. Direct installation is only necessary when building custom integrations or extensions.

Core Abstractions

Builder Interfaces

The framework uses three specialized builder interfaces for configuring different Lambda execution phases, providing clear separation of concerns:

ILambdaInvocationBuilder

Configures the Lambda invocation request/response pipeline:

  • Handle(LambdaInvocationDelegate handler) – Register the Lambda invocation handler that processes each incoming event
  • Use(Func<LambdaInvocationDelegate, LambdaInvocationDelegate> middleware) – Add middleware to the invocation pipeline; middleware is composed sequentially and can inspect/modify the context before and after invocation
  • Handler (property) – The currently registered invocation handler
  • Middlewares (property) – Collection of registered middleware components
  • Properties (property) – Key/value collection for sharing between the builder phases and all invocations
  • Services (property) – IServiceProvider for accessing registered services during configuration
  • Build() – Compiles the configured handler and middleware into an executable LambdaInvocationDelegate

ILambdaOnInitBuilder

Configures the initialization phase (runs once on cold start):

  • OnInit(LambdaInitDelegate handler) – Register initialization handlers that run before the first invocation; handlers are executed and return true to proceed or false to abort initialization
  • InitHandlers (property) – Collection of registered initialization handlers
  • Services (property) – IServiceProvider for accessing registered services during configuration
  • Build() – Compiles the configured handlers into an executable initialization delegate with concurrent execution and error aggregation

ILambdaOnShutdownBuilder

Configures the shutdown phase (runs once before Lambda termination):

  • OnShutdown(LambdaShutdownDelegate handler) – Register shutdown handlers that run during cleanup; handlers execute sequentially for graceful resource release
  • ShutdownHandlers (property) – Collection of registered shutdown handlers
  • Services (property) – IServiceProvider for accessing registered services during configuration
  • Build() – Compiles the configured handlers into an executable shutdown delegate with sequential execution and error logging

These interfaces are obtained from LambdaApplication after calling Build(). The builder pattern flow is:

LambdaApplication.CreateBuilder()
  → Configure services
    → .Build()
      → Returns LambdaApplication (implementing all three builder interfaces)
        → Configure invocation pipeline (ILambdaInvocationBuilder)
        → Configure init handlers (ILambdaOnInitBuilder)
        → Configure shutdown handlers (ILambdaOnShutdownBuilder)

This design separates concerns between request/response handling, initialization, and lifecycle cleanup. See MinimalLambda for detailed usage examples and the complete builder API.

ILambdaInvocationContext

Encapsulates a single Lambda invocation and provides access to contextual information and services:

  • ServiceProvider – Access to the scoped DI container for resolving services during invocation
  • CancellationToken – Cancellation signal triggered when Lambda approaches its timeout, allowing graceful shutdown
  • FeaturesIFeatureCollection providing access to custom functionalaty within the invocation pipeline such as for accessing the invocation Event or Response data
  • ItemsIDictionary<object, object?> for storing invocation-scoped data; cleared per invocation
  • PropertiesIDictionary<string, object?> for accessing shared data configured during the build phase; persists across invocations
  • RawInvocationData – Raw stream access to serialized event and response data via RawInvocationData.Event and RawInvocationData.Response
Properties vs Items

Properties and Items serve different purposes:

  • Properties: Configured during the build phase and available for the lifetime of the Lambda function. Use this for data that should be shared across invocations (e.g., configuration values set during initialization).
  • Items: Scoped to a single invocation and cleared after each request completes. Use this for temporary state that is specific to a single Lambda invocation.

ILambdaCancellationFactory

Provides a factory for creating cancellation token sources configured for AWS Lambda invocations:

  • NewCancellationTokenSource(ILambdaContext) – Creates a CancellationTokenSource that cancels before the Lambda function timeout, allowing time for graceful shutdown

This interface enables custom implementations for managing cancellation tokens with respect to Lambda's remaining execution time. The default implementation applies a configurable buffer duration to ensure operations complete before the Lambda runtime's hard timeout.

Envelope Abstractions

IRequestEnvelope

Defines a contract for extracting and deserializing incoming Lambda event payloads. Implementations extract the inner payload from the outer Lambda event structure and deserialize it for handler processing.

IResponseEnvelope

Defines a contract for serializing and packing handler results into Lambda response structures. Implementations serialize the handler result and place it in the appropriate location within the outer response structure.

These abstractions enable strongly-typed handling of AWS Lambda events (like API Gateway, SQS) with automatic payload extraction and response packing. See the envelope packages for concrete implementations.

Handler Delegates

LambdaInvocationDelegate

Task LambdaInvocationDelegate(ILambdaInvocationContext context)

Processes a Lambda invocation.

LambdaInitDelegate

Task<bool> LambdaInitDelegate(IServiceProvider services, CancellationToken cancellationToken)

Runs once during initialization. Return true to continue, false to abort.

LambdaShutdownDelegate

Task LambdaShutdownDelegate(IServiceProvider services, CancellationToken cancellationToken)

Runs once during shutdown for cleanup.

Lambda Lifecycle

The abstractions represent three Lambda execution phases:

  • InitLambdaInitDelegate runs once during function initialization
  • InvocationLambdaInvocationDelegate runs for each event
  • ShutdownLambdaShutdownDelegate runs once before termination

For implementation details and examples, see MinimalLambda.

Other Packages

Additional packages in the minimal-lambda framework for abstractions, observability, and event source handling.

Package NuGet Downloads
MinimalLambda NuGet Downloads
MinimalLambda.Abstractions NuGet Downloads
MinimalLambda.OpenTelemetry NuGet Downloads
MinimalLambda.Testing NuGet Downloads
MinimalLambda.Envelopes NuGet Downloads
MinimalLambda.Envelopes.Sqs NuGet Downloads
MinimalLambda.Envelopes.ApiGateway NuGet Downloads
MinimalLambda.Envelopes.Sns NuGet Downloads
MinimalLambda.Envelopes.Kinesis NuGet Downloads
MinimalLambda.Envelopes.KinesisFirehose NuGet Downloads
MinimalLambda.Envelopes.Kafka NuGet Downloads
MinimalLambda.Envelopes.CloudWatchLogs NuGet Downloads
MinimalLambda.Envelopes.Alb NuGet Downloads

License

This project is licensed under the MIT License. See LICENSE for details.

Product 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (12)

Showing the top 5 NuGet packages that depend on MinimalLambda.Abstractions:

Package Downloads
MinimalLambda

Minimal API-style framework for AWS Lambda functions

MinimalLambda.OpenTelemetry

OpenTelemetry integration for MinimalLambda

MinimalLambda.Envelopes.Sns

Strongly-typed SNS event envelopes

MinimalLambda.Envelopes.ApiGateway

Strongly-typed API Gateway event envelopes

MinimalLambda.Envelopes.Alb

Strongly-typed Application Load Balancer event envelopes

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-beta.11 0 12/17/2025
2.0.0-beta.10 24 12/17/2025
2.0.0-beta.9 48 12/15/2025
2.0.0-beta.8 40 12/15/2025
2.0.0-beta.7 40 12/15/2025
2.0.0-beta.6 43 12/14/2025
2.0.0-beta.5 36 12/14/2025
2.0.0-beta.4 42 12/13/2025
2.0.0-beta.3 84 12/12/2025
2.0.0-beta.2 60 12/12/2025
2.0.0-beta.1 73 12/11/2025