Goa.Clients.EventBridge 0.0.3-preview.1

This is a prerelease version of Goa.Clients.EventBridge.
dotnet add package Goa.Clients.EventBridge --version 0.0.3-preview.1
                    
NuGet\Install-Package Goa.Clients.EventBridge -Version 0.0.3-preview.1
                    
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.Clients.EventBridge" Version="0.0.3-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Goa.Clients.EventBridge" Version="0.0.3-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="Goa.Clients.EventBridge" />
                    
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.Clients.EventBridge --version 0.0.3-preview.1
                    
#r "nuget: Goa.Clients.EventBridge, 0.0.3-preview.1"
                    
#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.Clients.EventBridge@0.0.3-preview.1
                    
#: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.Clients.EventBridge&version=0.0.3-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Goa.Clients.EventBridge&version=0.0.3-preview.1&prerelease
                    
Install as a Cake Tool

Goa.Clients.EventBridge

EventBridge client for event routing in high-performance AWS Lambda functions. This package provides a lightweight, AOT-ready EventBridge client optimized for minimal cold start times.

Installation

dotnet add package Goa.Clients.EventBridge

Features

  • Native AOT support for faster Lambda cold starts
  • Minimal dependencies and memory allocations
  • Built-in error handling with ErrorOr pattern
  • Type-safe event publishing
  • Support for custom event buses and rules
  • Batch event publishing (up to 10 events per request)

Usage

Basic Setup

using Goa.Clients.EventBridge;
using Microsoft.Extensions.DependencyInjection;

// Register EventBridge client
services.AddEventBridge();

// Or with custom configuration
services.AddEventBridge(config =>
{
    config.ServiceUrl = "http://localhost:4566"; // For LocalStack
    config.Region = "us-west-2";
    config.LogLevel = LogLevel.Debug;
});

Publishing Events

using System.Text.Json;
using ErrorOr;
using Goa.Clients.EventBridge;
using Goa.Clients.EventBridge.Models;
using Goa.Clients.EventBridge.Operations.PutEvents;

public class OrderService
{
    private readonly IEventBridgeClient _eventBridge;
    
    public OrderService(IEventBridgeClient eventBridge)
    {
        _eventBridge = eventBridge;
    }
    
    public async Task<ErrorOr<Success>> PublishOrderCreatedAsync(Order order)
    {
        var eventDetail = new
        {
            OrderId = order.Id,
            CustomerId = order.CustomerId,
            Total = order.Total
        };
        
        var request = new PutEventsRequest
        {
            Entries = new List<EventEntry>
            {
                new EventEntry
                {
                    Source = "myapp.orders",
                    DetailType = "Order Created",
                    Detail = JsonSerializer.Serialize(eventDetail),
                    Time = DateTime.UtcNow
                }
            }
        };
        
        var result = await _eventBridge.PutEventsAsync(request);
        return result.IsError ? result.FirstError : Result.Success;
    }
}

Custom Event Bus

public async Task<ErrorOr<Success>> PublishToCustomBusAsync()
{
    var eventDetail = new { ProductId = "123", Quantity = 50 };
    
    var request = new PutEventsRequest
    {
        Entries = new List<EventEntry>
        {
            new EventEntry
            {
                Source = "myapp.inventory",
                DetailType = "Stock Updated",
                Detail = JsonSerializer.Serialize(eventDetail),
                EventBusName = "my-custom-bus",
                Time = DateTime.UtcNow
            }
        }
    };
    
    var result = await _eventBridge.PutEventsAsync(request);
    return result.IsError ? result.FirstError : Result.Success;
}

Batch Events

public async Task<ErrorOr<Success>> PublishMultipleEventsAsync()
{
    var request = new PutEventsRequest
    {
        Entries = new List<EventEntry>
        {
            new EventEntry
            {
                Source = "myapp.orders",
                DetailType = "Order Created",
                Detail = JsonSerializer.Serialize(new { OrderId = "123" }),
                Time = DateTime.UtcNow
            },
            new EventEntry
            {
                Source = "myapp.inventory", 
                DetailType = "Stock Updated",
                Detail = JsonSerializer.Serialize(new { ProductId = "456" }),
                Time = DateTime.UtcNow
            },
            new EventEntry
            {
                Source = "myapp.notifications",
                DetailType = "Email Sent", 
                Detail = JsonSerializer.Serialize(new { UserId = "789" }),
                Time = DateTime.UtcNow
            }
        }
    };
    
    var result = await _eventBridge.PutEventsAsync(request);
    return result.IsError ? result.FirstError : Result.Success;
}

Error Handling

var result = await _eventBridge.PutEventsAsync(request);

if (result.IsError)
{
    // Handle errors
    foreach (var error in result.Errors)
    {
        Console.WriteLine($"EventBridge Error: {error.Description}");
    }
    return;
}

// Check for failed entries in the response
var response = result.Value;
if (response.FailedEntryCount > 0)
{
    foreach (var failedEntry in response.Entries.Where(e => e.ErrorCode != null))
    {
        Console.WriteLine($"Failed to publish event: {failedEntry.ErrorCode} - {failedEntry.ErrorMessage}");
    }
}

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 47 8/23/2025
0.0.2-preview.2.3 111 8/18/2025
0.0.2-preview.2.2 132 8/17/2025
0.0.2-preview.2.1 86 8/17/2025
0.0.2-preview.2 185 8/9/2025
0.0.0-alpha.0.32 85 12/7/2024
0.0.0-alpha.0.20 71 10/27/2024