aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.Database/Jellyfin.Database.Implementations/Locking/IEntityFrameworkCoreLockingBehavior.cs
blob: 465c31212246cb2badfdbae47a7c061e6341bc6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace Jellyfin.Database.Implementations.Locking;

/// <summary>
/// Defines a jellyfin locking behavior that can be configured.
/// </summary>
public interface IEntityFrameworkCoreLockingBehavior
{
    /// <summary>
    /// Provides access to the builder to setup any connection related locking behavior.
    /// </summary>
    /// <param name="optionsBuilder">The options builder.</param>
    void Initialise(DbContextOptionsBuilder optionsBuilder);

    /// <summary>
    /// Will be invoked when changes should be saved in the current locking behavior.
    /// </summary>
    /// <param name="context">The database context invoking the action.</param>
    /// <param name="saveChanges">Callback for performing the actual save changes.</param>
    void OnSaveChanges(JellyfinDbContext context, Action saveChanges);

    /// <summary>
    /// Will be invoked when changes should be saved in the current locking behavior.
    /// </summary>
    /// <param name="context">The database context invoking the action.</param>
    /// <param name="saveChanges">Callback for performing the actual save changes.</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    Task OnSaveChangesAsync(JellyfinDbContext context, Func<Task> saveChanges);
}