Pavas.Patterns.Outbox
1.0.0
See the version list below for details.
dotnet add package Pavas.Patterns.Outbox --version 1.0.0
NuGet\Install-Package Pavas.Patterns.Outbox -Version 1.0.0
<PackageReference Include="Pavas.Patterns.Outbox" Version="1.0.0" />
paket add Pavas.Patterns.Outbox --version 1.0.0
#r "nuget: Pavas.Patterns.Outbox, 1.0.0"
// Install Pavas.Patterns.Outbox as a Cake Addin #addin nuget:?package=Pavas.Patterns.Outbox&version=1.0.0 // Install Pavas.Patterns.Outbox as a Cake Tool #tool nuget:?package=Pavas.Patterns.Outbox&version=1.0.0
Pavas.Patterns.Outbox
The Pavas.Patterns.Outbox
NuGet package provides an interface and utility extensions for handling outbox pattern events. This package simplifies the process of handling event-driven systems by managing the state of events and their payloads through extensions, including marking events as pending, sent, or failed.
Features
- Define an outbox event using the
IOutboxEvent
interface. - Serialize and handle event payloads via extension methods.
- Track event states (
Pending
,Published
,Fail
) using a simple, intuitive API. - Utilities to mark events as
Pending
,Sent
, orFail
.
Installation
To install the NuGet package, run the following command in the .NET CLI:
dotnet add package Pavas.Patterns.Outbox
Or through the NuGet Package Manager:
Install-Package Pavas.Patterns.Outbox
Usage
Define Outbox Events
Implement the IOutboxEvent
interface in your event classes:
namespace MyApp.Events
{
public class MyOutboxEvent : IOutboxEvent
{
public int Id { get; init; }
public string EventType { get; set; }
public string Payload { get; set; }
public string Status { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? PublishedAt { get; set; }
public DateTime? FailedAt { get; set; }
}
}
Serialize Payloads
Use the extension method SerializePayload
to serialize your event payload:
var myEvent = new MyOutboxEvent();
myEvent.SerializePayload(new { Message = "Hello, World!" });
Mark Event Status
Update the event's status using the provided extension methods:
- Mark as Pending:
myEvent.MarkAsPending();
- Mark as Sent:
myEvent.MarkAsSent();
- Mark as Failed:
myEvent.MarkAsFail();
Event States
The outbox event can have the following states:
- Pending: The event is ready to be processed.
- Published: The event has been successfully processed and published.
- Fail: The event processing has failed.
Contributing
Feel free to open issues or pull requests if you encounter bugs or have suggestions for improvements.
License
This project is licensed under the MIT License.
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. net9.0 was computed. 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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.