Added Event Tracking!
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using FinancialApi.Application;
|
||||
|
||||
namespace FinancialApi;
|
||||
|
||||
public class DemoEventStore : IEventTracker
|
||||
{
|
||||
public List<string> CapturedEvents { get; } = new();
|
||||
|
||||
public void Add(string eventMessage)
|
||||
{
|
||||
CapturedEvents.Add($"[{DateTimeOffset.UtcNow:HH:mm:ss}] {eventMessage}");
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,11 @@ POST {{FinancialApi_HostAddress}}/journal/reverse
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"originalJournalId": "3E829F92-E2FA-4FCD-9B7B-E1B5AAC96FF1",
|
||||
"originalJournalId": "1443B0FC-F679-4445-A910-CC333F0925B7",
|
||||
"reason": "Incorrect Account Fee"
|
||||
}
|
||||
|
||||
### Events
|
||||
|
||||
GET {{FinancialApi_HostAddress}}/events
|
||||
Content-Type: application/json
|
||||
@@ -22,6 +22,7 @@ builder.Services.AddDbContext<AccountDbContext>(options =>
|
||||
|
||||
builder.Services.AddScoped<IAccountQuery, AccountQuery>();
|
||||
builder.Services.AddScoped<IReversalQuery, ReversalQuery>();
|
||||
builder.Services.AddSingleton<IEventTracker, DemoEventStore>();
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
@@ -31,6 +32,7 @@ builder.AddServiceDefaults();
|
||||
|
||||
builder.Host.UseWolverine(opts =>
|
||||
{
|
||||
opts.Discovery.IncludeAssembly(typeof(DemoEventStore).Assembly);
|
||||
opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly);
|
||||
opts.PersistMessagesWithSqlite(connectionString);
|
||||
opts.UseEntityFrameworkCoreTransactions();
|
||||
@@ -74,4 +76,13 @@ app.MapPost("/journal/reverse", async (ReverseJournalCommand cmd, IMessageBus bu
|
||||
return Results.Accepted();
|
||||
});
|
||||
|
||||
app.MapGet("/events", (IEventTracker tracker) =>
|
||||
{
|
||||
if (tracker is DemoEventStore store)
|
||||
{
|
||||
return Results.Ok(store.CapturedEvents);
|
||||
}
|
||||
return Results.NotFound();
|
||||
});
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user