diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-09-02 18:24:28 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2024-09-02 18:24:28 -0500 |
| commit | 18edc102e0c2a7aca57a98ca27494a93e890c253 (patch) | |
| tree | 86f7f351021956a1a31f1678b261ae5eb242679c /src | |
| parent | 9657cb704b3a26f6e082331e8dcba14507e2cf53 (diff) | |
| download | slskd-18edc102e0c2a7aca57a98ca27494a93e890c253.tar.gz | |
use EventService instead of dbcontext
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Events/EventBus.cs | 13 |
1 files changed, 5 insertions, 8 deletions
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; /// <summary> @@ -48,14 +47,14 @@ public class EventBus /// <summary> /// Initializes a new instance of the <see cref="EventBus"/> class. /// </summary> - /// <param name="contextFactory"/> - public EventBus(IDbContextFactory<EventsDbContext> contextFactory) + /// <param name="eventService"/> + public EventBus(EventService eventService) { - ContextFactory = contextFactory; + Events = eventService; } private ILogger Log { get; } = Serilog.Log.ForContext<EventBus>(); - private IDbContextFactory<EventsDbContext> ContextFactory { get; } + private EventService Events { get; } /// <summary> /// 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<T>(data)); - ctx.SaveChanges(); + Events.Add(EventRecord.From<T>(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 |
