From 18edc102e0c2a7aca57a98ca27494a93e890c253 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 2 Sep 2024 18:24:28 -0500 Subject: use EventService instead of dbcontext --- src/slskd/Events/EventBus.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/slskd/Events/EventBus.cs b/src/slskd/Events/EventBus.cs index d51e2fd7..bc05e1b8 100644 --- a/src/slskd/Events/EventBus.cs +++ b/src/slskd/Events/EventBus.cs @@ -22,7 +22,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; using Serilog; /// @@ -48,14 +47,14 @@ public class EventBus /// /// Initializes a new instance of the class. /// - /// - public EventBus(IDbContextFactory contextFactory) + /// + public EventBus(EventService eventService) { - ContextFactory = contextFactory; + Events = eventService; } private ILogger Log { get; } = Serilog.Log.ForContext(); - private IDbContextFactory ContextFactory { get; } + private EventService Events { get; } /// /// Gets the internal list of event subscriptions. @@ -77,9 +76,7 @@ public class EventBus Log.Debug("Handling {Type}: {Data}", typeof(T), data); // save the event to the database before broadcasting to consumers - var ctx = ContextFactory.CreateDbContext(); - ctx.Add(EventRecord.From(data)); - ctx.SaveChanges(); + Events.Add(EventRecord.From(data)); // broadcast the event in a fire-and-forget fashion // we don't need to wait for anything, just need to kick off the tasks -- cgit v1.2.3