propagate shared-config and library-option changes between instances
Add a Redis pub/sub invalidation bus, publish from the configuration and library-option write paths, and drop the matching local cache entry on the instances that did not write. No-op without a Redis connection string, and fails open when it is unreachable.
This commit is contained in:
@@ -87,6 +87,12 @@ namespace Emby.Server.Implementations.AppBase
|
||||
/// <value>The application paths.</value>
|
||||
public IApplicationPaths CommonApplicationPaths { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bus announcing configuration writes to the other instances sharing this
|
||||
/// configuration directory. Defaults to a no-op, which is the single-instance behaviour.
|
||||
/// </summary>
|
||||
public IConfigurationInvalidationBus InvalidationBus { get; set; } = NullConfigurationInvalidationBus.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the system configuration.
|
||||
/// </summary>
|
||||
@@ -169,6 +175,8 @@ namespace Emby.Server.Implementations.AppBase
|
||||
}
|
||||
|
||||
OnConfigurationUpdated();
|
||||
|
||||
InvalidationBus.Publish(ConfigurationInvalidationScope.SystemConfiguration, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -350,6 +358,29 @@ namespace Emby.Server.Implementations.AppBase
|
||||
}
|
||||
|
||||
OnNamedConfigurationUpdated(key, configuration);
|
||||
|
||||
InvalidationBus.Publish(ConfigurationInvalidationScope.NamedConfiguration, key);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void InvalidateCachedConfiguration(string? key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
lock (_configurationSyncLock)
|
||||
{
|
||||
_configuration = null;
|
||||
}
|
||||
|
||||
// Reloads the system configuration off the shared file as a side effect of re-deriving
|
||||
// the cache path from it, then tells the in-process consumers to re-read it.
|
||||
OnConfigurationUpdated();
|
||||
return;
|
||||
}
|
||||
|
||||
_configurations.TryRemove(key, out _);
|
||||
|
||||
OnNamedConfigurationUpdated(key, GetConfiguration(key));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user