From a1d72deba2cb22006af5e286cc3bb23203ec727f Mon Sep 17 00:00:00 2001 From: JPVenson Date: Wed, 4 Jun 2025 00:15:22 +0300 Subject: Add multiple options for internal locking (#14047) --- .../Locking/IEntityFrameworkCoreLockingBehavior.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Jellyfin.Database/Jellyfin.Database.Implementations/Locking/IEntityFrameworkCoreLockingBehavior.cs (limited to 'src/Jellyfin.Database/Jellyfin.Database.Implementations/Locking/IEntityFrameworkCoreLockingBehavior.cs') diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/Locking/IEntityFrameworkCoreLockingBehavior.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/Locking/IEntityFrameworkCoreLockingBehavior.cs new file mode 100644 index 000000000..465c31212 --- /dev/null +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/Locking/IEntityFrameworkCoreLockingBehavior.cs @@ -0,0 +1,32 @@ +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +namespace Jellyfin.Database.Implementations.Locking; + +/// +/// Defines a jellyfin locking behavior that can be configured. +/// +public interface IEntityFrameworkCoreLockingBehavior +{ + /// + /// Provides access to the builder to setup any connection related locking behavior. + /// + /// The options builder. + void Initialise(DbContextOptionsBuilder optionsBuilder); + + /// + /// Will be invoked when changes should be saved in the current locking behavior. + /// + /// The database context invoking the action. + /// Callback for performing the actual save changes. + void OnSaveChanges(JellyfinDbContext context, Action saveChanges); + + /// + /// Will be invoked when changes should be saved in the current locking behavior. + /// + /// The database context invoking the action. + /// Callback for performing the actual save changes. + /// A representing the asynchronous operation. + Task OnSaveChangesAsync(JellyfinDbContext context, Func saveChanges); +} -- cgit v1.2.3