From 916e897ed25f74b0112e51758e673f18ad13af1d Mon Sep 17 00:00:00 2001 From: JPVenson Date: Wed, 4 Jun 2025 01:53:37 +0300 Subject: Allow custom plugin provided database providers to be loaded (#14171) --- .../DbConfiguration/CustomDatabaseOption.cs | 19 +++++++++++++ .../DbConfiguration/CustomDatabaseOptions.cs | 32 ++++++++++++++++++++++ .../DatabaseConfigurationOptions.cs | 7 +++++ 3 files changed, 58 insertions(+) create mode 100644 src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOption.cs create mode 100644 src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOptions.cs (limited to 'src') diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOption.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOption.cs new file mode 100644 index 000000000..fcb8f41b3 --- /dev/null +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOption.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Jellyfin.Database.Implementations.DbConfiguration; + +/// +/// The custom value option for custom database providers. +/// +public class CustomDatabaseOption +{ + /// + /// Gets or sets the key of the value. + /// + public required string Key { get; set; } + + /// + /// Gets or sets the value. + /// + public required string Value { get; set; } +} diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOptions.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOptions.cs new file mode 100644 index 000000000..e2088704d --- /dev/null +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/CustomDatabaseOptions.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Jellyfin.Database.Implementations.DbConfiguration; + +/// +/// Defines the options for a custom database connector. +/// +public class CustomDatabaseOptions +{ + /// + /// Gets or sets the Plugin name to search for database providers. + /// + public required string PluginName { get; set; } + + /// + /// Gets or sets the plugin assembly to search for providers. + /// + public required string PluginAssembly { get; set; } + + /// + /// Gets or sets the connection string for the custom database provider. + /// + public required string ConnectionString { get; set; } + + /// + /// Gets or sets the list of extra options for the custom provider. + /// +#pragma warning disable CA2227 // Collection properties should be read only + public Collection Options { get; set; } = []; +#pragma warning restore CA2227 // Collection properties should be read only +} diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs index 682e5019b..bc0cacf3c 100644 --- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace Jellyfin.Database.Implementations.DbConfiguration; /// @@ -10,6 +12,11 @@ public class DatabaseConfigurationOptions /// public required string DatabaseType { get; set; } + /// + /// Gets or sets the options required to use a custom database provider. + /// + public CustomDatabaseOptions? CustomProviderOptions { get; set; } + /// /// Gets or Sets the kind of locking behavior jellyfin should perform. Possible options are "NoLock", "Pessimistic", "Optimistic". /// Defaults to "NoLock". -- cgit v1.2.3