IJellyfinDatabaseProvider.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. using Microsoft.EntityFrameworkCore;
  5. namespace Jellyfin.Server.Implementations;
  6. /// <summary>
  7. /// Defines the type and extension points for multi database support.
  8. /// </summary>
  9. public interface IJellyfinDatabaseProvider
  10. {
  11. /// <summary>
  12. /// Gets or Sets the Database Factory when initialisaition is done.
  13. /// </summary>
  14. IDbContextFactory<JellyfinDbContext>? DbContextFactory { get; set; }
  15. /// <summary>
  16. /// Initialises jellyfins EFCore database access.
  17. /// </summary>
  18. /// <param name="options">The EFCore database options.</param>
  19. void Initialise(DbContextOptionsBuilder options);
  20. /// <summary>
  21. /// Will be invoked when EFCore wants to build its model.
  22. /// </summary>
  23. /// <param name="modelBuilder">The ModelBuilder from EFCore.</param>
  24. void OnModelCreating(ModelBuilder modelBuilder);
  25. /// <summary>
  26. /// If supported this should run any periodic maintaince tasks.
  27. /// </summary>
  28. /// <param name="cancellationToken">The token to abort the operation.</param>
  29. /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
  30. Task RunScheduledOptimisation(CancellationToken cancellationToken);
  31. /// <summary>
  32. /// If supported this should perform any actions that are required on stopping the jellyfin server.
  33. /// </summary>
  34. /// <param name="cancellationToken">The token that will be used to abort the operation.</param>
  35. /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
  36. Task RunShutdownTask(CancellationToken cancellationToken);
  37. }