Goa.Functions.Dynamo 0.0.2-preview.2.2

This is a prerelease version of Goa.Functions.Dynamo.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Goa.Functions.Dynamo --version 0.0.2-preview.2.2
                    
NuGet\Install-Package Goa.Functions.Dynamo -Version 0.0.2-preview.2.2
                    
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="Goa.Functions.Dynamo" Version="0.0.2-preview.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Goa.Functions.Dynamo" Version="0.0.2-preview.2.2" />
                    
Directory.Packages.props
<PackageReference Include="Goa.Functions.Dynamo" />
                    
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 Goa.Functions.Dynamo --version 0.0.2-preview.2.2
                    
#r "nuget: Goa.Functions.Dynamo, 0.0.2-preview.2.2"
                    
#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 Goa.Functions.Dynamo@0.0.2-preview.2.2
                    
#: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=Goa.Functions.Dynamo&version=0.0.2-preview.2.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Goa.Functions.Dynamo&version=0.0.2-preview.2.2&prerelease
                    
Install as a Cake Tool

Goa.Functions.Dynamo

DynamoDB stream processing for high-performance AWS Lambda functions. This package provides streamlined processing of DynamoDB streams with type-safe event handling and minimal overhead.

Installation

dotnet add package Goa.Functions.Dynamo

Features

  • Native AOT support for faster Lambda cold starts
  • Type-safe DynamoDB stream event processing
  • Built-in error handling and retry logic
  • Support for single and batch record processing
  • Integration with Goa.Clients.Dynamo for seamless data access
  • Minimal dependencies and optimized performance

Usage

Basic Stream Processing

using Goa.Functions.Dynamo;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = Host.CreateDefaultBuilder(args)
    .ConfigureGoaFunction(services =>
    {
        services.AddGoaDynamoFunction();
        services.AddScoped<IUserProcessor, UserProcessor>();
    });

var app = builder.Build();
await app.RunGoaDynamoFunctionAsync<UserStreamHandler>();

public class UserStreamHandler : ISingleRecordHandler<User>
{
    private readonly IUserProcessor _processor;
    private readonly ILogger<UserStreamHandler> _logger;
    
    public UserStreamHandler(IUserProcessor processor, ILogger<UserStreamHandler> logger)
    {
        _processor = processor;
        _logger = logger;
    }
    
    public async Task<ProcessResult> HandleAsync(
        DynamoDbStreamRecord<User> record, 
        CancellationToken cancellationToken = default)
    {
        _logger.LogInformation("Processing {Operation} for user {UserId}", 
            record.EventName, record.Dynamodb.NewImage?.Id);
            
        return record.EventName switch
        {
            DynamoStreamOperation.Insert => await _processor.HandleInsertAsync(record.Dynamodb.NewImage),
            DynamoStreamOperation.Modify => await _processor.HandleUpdateAsync(
                record.Dynamodb.OldImage, record.Dynamodb.NewImage),
            DynamoStreamOperation.Remove => await _processor.HandleDeleteAsync(record.Dynamodb.OldImage),
            _ => ProcessResult.Success()
        };
    }
}

Batch Processing

public class OrderBatchHandler : IMultipleRecordHandler<Order>
{
    private readonly IOrderProcessor _processor;
    
    public OrderBatchHandler(IOrderProcessor processor)
    {
        _processor = processor;
    }
    
    public async Task<BatchProcessResult> HandleAsync(
        IReadOnlyList<DynamoDbStreamRecord<Order>> records, 
        CancellationToken cancellationToken = default)
    {
        var results = new List<ProcessResult>();
        
        foreach (var record in records)
        {
            var result = await ProcessSingleRecord(record, cancellationToken);
            results.Add(result);
        }
        
        return new BatchProcessResult(results);
    }
    
    private async Task<ProcessResult> ProcessSingleRecord(
        DynamoDbStreamRecord<Order> record, 
        CancellationToken cancellationToken)
    {
        // Process individual record
        return ProcessResult.Success();
    }
}

Using Function Builder

public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = new DynamoDbFunctionBuilder()
            .ConfigureServices(services =>
            {
                services.AddScoped<IInventoryService, InventoryService>();
            })
            .UseSingleRecordProcessing<Product, ProductHandler>()
            .WithErrorHandling(options =>
            {
                options.MaxRetries = 3;
                options.RetryDelay = TimeSpan.FromSeconds(5);
            });
            
        await builder.RunAsync();
    }
}

Stream View Types

The package supports all DynamoDB stream view types:

// Handle different view types
public async Task<ProcessResult> HandleAsync(DynamoDbStreamRecord<User> record, CancellationToken cancellationToken)
{
    return record.Dynamodb.StreamViewType switch
    {
        StreamViewType.KeysOnly => await HandleKeysOnly(record),
        StreamViewType.NewImage => await HandleNewImage(record),
        StreamViewType.OldImage => await HandleOldImage(record),
        StreamViewType.NewAndOldImages => await HandleBothImages(record),
        _ => ProcessResult.Success()
    };
}

Event Processing Options

  • Single Record Processing: Process one record at a time with ISingleRecordHandler<T>
  • Batch Processing: Process multiple records together with IMultipleRecordHandler<T>
  • Processing Type: Configure sequential or parallel processing modes

Documentation

For more information and examples, visit the main Goa documentation.

Product Compatible and additional computed target framework versions.
.NET 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

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
0.0.3-preview.1 46 8/23/2025
0.0.2-preview.2.3 112 8/18/2025
0.0.2-preview.2.2 129 8/17/2025
0.0.2-preview.2.1 115 8/17/2025
0.0.2-preview.2 192 8/9/2025
0.0.0-alpha.0.32 76 12/7/2024
0.0.0-alpha.0.20 76 10/27/2024