some changes

This commit is contained in:
john 2025-05-17 23:47:19 +02:00
parent 4ec9720541
commit b47bac67ca
37 changed files with 397 additions and 190 deletions

View file

@ -9,21 +9,23 @@ namespace Femto.Common.Infrastructure.Outbox;
public static class OutboxServiceExtension
{
public static void AddOutbox<TContext>(
public static void AddOutbox<TContext, TMessageHandler>(
this IServiceCollection services,
Func<IServiceProvider, TContext>? contextFactory = null
)
where TContext : DbContext, IOutboxContext
where TMessageHandler : class, IOutboxMessageHandler
{
services.AddSingleton<IOutboxMessageMapping, ClrTypenameMessageMapping>();
services.AddScoped<IOutboxContext>(c =>
contextFactory?.Invoke(c) ?? c.GetRequiredService<TContext>()
);
services.AddScoped<Outbox<TContext>>();
services.AddScoped<IOutboxMessageHandler, TMessageHandler>();
services.AddQuartz(q =>
{
var jobKey = JobKey.Create(nameof(OutboxProcessor<TContext>));