mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-31 09:02:41 +01:00
More Options snapshot/monitor conversions
This commit is contained in:
@@ -62,9 +62,9 @@ namespace Tgstation.Server.Host.Authority
|
||||
readonly ISessionInvalidationTracker sessionInvalidationTracker;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SecurityConfiguration"/> for the <see cref="LoginAuthority"/>.
|
||||
/// The <see cref="IOptionsSnapshot{TOptions}"/> containing the <see cref="SecurityConfiguration"/> for the <see cref="LoginAuthority"/>.
|
||||
/// </summary>
|
||||
readonly SecurityConfiguration securityConfiguration;
|
||||
readonly IOptionsSnapshot<SecurityConfiguration> securityConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Generate an <see cref="AuthorityResponse{TResult}"/> for a given <paramref name="headersException"/>.
|
||||
@@ -113,7 +113,7 @@ namespace Tgstation.Server.Host.Authority
|
||||
/// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/>.</param>
|
||||
/// <param name="identityCache">The value of <see cref="identityCache"/>.</param>
|
||||
/// <param name="sessionInvalidationTracker">The value of <see cref="sessionInvalidationTracker"/>.</param>
|
||||
/// <param name="securityConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="securityConfiguration"/>.</param>
|
||||
/// <param name="securityConfigurationOptions">The value of <see cref="securityConfigurationOptions"/>.</param>
|
||||
public LoginAuthority(
|
||||
IDatabaseContext databaseContext,
|
||||
ILogger<LoginAuthority> logger,
|
||||
@@ -124,7 +124,7 @@ namespace Tgstation.Server.Host.Authority
|
||||
ICryptographySuite cryptographySuite,
|
||||
IIdentityCache identityCache,
|
||||
ISessionInvalidationTracker sessionInvalidationTracker,
|
||||
IOptions<SecurityConfiguration> securityConfigurationOptions)
|
||||
IOptionsSnapshot<SecurityConfiguration> securityConfigurationOptions)
|
||||
: base(
|
||||
databaseContext,
|
||||
logger)
|
||||
@@ -136,7 +136,7 @@ namespace Tgstation.Server.Host.Authority
|
||||
this.cryptographySuite = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
|
||||
this.identityCache = identityCache ?? throw new ArgumentNullException(nameof(identityCache));
|
||||
this.sessionInvalidationTracker = sessionInvalidationTracker ?? throw new ArgumentNullException(nameof(sessionInvalidationTracker));
|
||||
securityConfiguration = securityConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(securityConfigurationOptions));
|
||||
this.securityConfigurationOptions = securityConfigurationOptions ?? throw new ArgumentNullException(nameof(securityConfigurationOptions));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -181,7 +181,7 @@ namespace Tgstation.Server.Host.Authority
|
||||
private async ValueTask<AuthorityResponse<LoginResult>> AttemptLoginImpl(CancellationToken cancellationToken)
|
||||
{
|
||||
// password and oauth logins disabled
|
||||
if (securityConfiguration.OidcStrictMode)
|
||||
if (securityConfigurationOptions.Value.OidcStrictMode)
|
||||
return Unauthorized<LoginResult>();
|
||||
|
||||
var headers = apiHeadersProvider.ApiHeaders;
|
||||
|
||||
@@ -85,9 +85,9 @@ namespace Tgstation.Server.Host.Authority
|
||||
readonly IOptionsSnapshot<GeneralConfiguration> generalConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IOptions{TOptions}"/> of <see cref="SecurityConfiguration"/> for the <see cref="UserAuthority"/>.
|
||||
/// The <see cref="IOptionsSnapshot{TOptions}"/> of <see cref="SecurityConfiguration"/> for the <see cref="UserAuthority"/>.
|
||||
/// </summary>
|
||||
readonly IOptions<SecurityConfiguration> securityConfigurationOptions;
|
||||
readonly IOptionsSnapshot<SecurityConfiguration> securityConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Implements the <see cref="usersDataLoader"/>.
|
||||
@@ -218,7 +218,7 @@ namespace Tgstation.Server.Host.Authority
|
||||
ITopicEventSender topicEventSender,
|
||||
IClaimsPrincipalAccessor claimsPrincipalAccessor,
|
||||
IOptionsSnapshot<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<SecurityConfiguration> securityConfigurationOptions)
|
||||
IOptionsSnapshot<SecurityConfiguration> securityConfigurationOptions)
|
||||
: base(
|
||||
databaseContext,
|
||||
logger)
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Prometheus;
|
||||
|
||||
@@ -92,16 +93,16 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
/// </summary>
|
||||
readonly IAsyncDelayer asyncDelayer;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="SessionConfiguration"/> for <see cref="DreamMaker"/>.
|
||||
/// </summary>
|
||||
readonly IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ILogger"/> for <see cref="DreamMaker"/>.
|
||||
/// </summary>
|
||||
readonly ILogger<DreamMaker> logger;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SessionConfiguration"/> for <see cref="DreamMaker"/>.
|
||||
/// </summary>
|
||||
readonly SessionConfiguration sessionConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Instance"/> <see cref="DreamMaker"/> belongs to.
|
||||
/// </summary>
|
||||
@@ -167,8 +168,8 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
/// <param name="remoteDeploymentManagerFactory">The value of <see cref="remoteDeploymentManagerFactory"/>.</param>
|
||||
/// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
|
||||
/// <param name="metricFactory">The <see cref="IMetricFactory"/> to use.</param>
|
||||
/// <param name="sessionConfigurationOptions">The value of <see cref="sessionConfigurationOptions"/>.</param>
|
||||
/// <param name="logger">The value of <see cref="logger"/>.</param>
|
||||
/// <param name="sessionConfiguration">The value of <see cref="sessionConfiguration"/>.</param>
|
||||
/// <param name="metadata">The value of <see cref="metadata"/>.</param>
|
||||
public DreamMaker(
|
||||
IEngineManager engineManager,
|
||||
@@ -183,8 +184,8 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IMetricFactory metricFactory,
|
||||
IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions,
|
||||
ILogger<DreamMaker> logger,
|
||||
SessionConfiguration sessionConfiguration,
|
||||
Api.Models.Instance metadata)
|
||||
{
|
||||
this.engineManager = engineManager ?? throw new ArgumentNullException(nameof(engineManager));
|
||||
@@ -199,8 +200,8 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
this.remoteDeploymentManagerFactory = remoteDeploymentManagerFactory ?? throw new ArgumentNullException(nameof(remoteDeploymentManagerFactory));
|
||||
this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
|
||||
ArgumentNullException.ThrowIfNull(metricFactory);
|
||||
this.sessionConfigurationOptions = sessionConfigurationOptions ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
this.sessionConfiguration = sessionConfiguration ?? throw new ArgumentNullException(nameof(sessionConfiguration));
|
||||
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
|
||||
|
||||
successfulDeployments = metricFactory.CreateCounter("tgs_successful_deployments", "The number of deployments that have completed successfully");
|
||||
@@ -922,7 +923,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
readStandardHandles: true,
|
||||
noShellExecute: true);
|
||||
|
||||
if (sessionConfiguration.LowPriorityDeploymentProcesses)
|
||||
if (sessionConfigurationOptions.CurrentValue.LowPriorityDeploymentProcesses)
|
||||
dm.AdjustPriority(false);
|
||||
|
||||
int exitCode;
|
||||
@@ -1013,7 +1014,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
{
|
||||
async ValueTask CleanDir()
|
||||
{
|
||||
if (sessionConfiguration.DelayCleaningFailedDeployments)
|
||||
if (sessionConfigurationOptions.CurrentValue.DelayCleaningFailedDeployments)
|
||||
{
|
||||
logger.LogDebug("Not cleaning up errored deployment directory {guid} due to config.", job.DirectoryName);
|
||||
return;
|
||||
|
||||
@@ -91,8 +91,8 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// <param name="repositoryManager">The value of <see cref="repositoryManager"/>.</param>
|
||||
/// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
|
||||
/// <param name="httpClientFactory">The value of <see cref="httpClientFactory"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="GeneralConfiguration"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="SessionConfiguration"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptionsMonitor{TOptions}"/> containing value of <see cref="GeneralConfiguration"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptionsMonitor{TOptions}"/> containing value of <see cref="SessionConfiguration"/>.</param>
|
||||
public OpenDreamInstaller(
|
||||
IIOManager ioManager,
|
||||
ILogger<OpenDreamInstaller> logger,
|
||||
|
||||
@@ -150,14 +150,14 @@ namespace Tgstation.Server.Host.Components
|
||||
readonly IMetricFactory metricFactory;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GeneralConfiguration"/> for the <see cref="InstanceFactory"/>.
|
||||
/// The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="GeneralConfiguration"/> for the <see cref="InstanceFactory"/>.
|
||||
/// </summary>
|
||||
readonly GeneralConfiguration generalConfiguration;
|
||||
readonly IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SessionConfiguration"/> for the <see cref="InstanceFactory"/>.
|
||||
/// The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="SessionConfiguration"/> for the <see cref="InstanceFactory"/>.
|
||||
/// </summary>
|
||||
readonly SessionConfiguration sessionConfiguration;
|
||||
readonly IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Create the <see cref="IIOManager"/> pointing to the "Game" directory of a given <paramref name="instanceIOManager"/>.
|
||||
@@ -193,8 +193,8 @@ namespace Tgstation.Server.Host.Components
|
||||
/// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
|
||||
/// <param name="dotnetDumpService">The value of <see cref="dotnetDumpService"/>.</param>
|
||||
/// <param name="metricFactory">The value of <see cref="metricFactory"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="sessionConfiguration"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The value of <see cref="generalConfigurationOptions"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The value of <see cref="sessionConfigurationOptions"/>.</param>
|
||||
public InstanceFactory(
|
||||
IIOManager ioManager,
|
||||
IDatabaseContextFactory databaseContextFactory,
|
||||
@@ -219,8 +219,8 @@ namespace Tgstation.Server.Host.Components
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IDotnetDumpService dotnetDumpService,
|
||||
IMetricFactory metricFactory,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<SessionConfiguration> sessionConfigurationOptions)
|
||||
IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions)
|
||||
{
|
||||
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
|
||||
this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
|
||||
@@ -245,8 +245,8 @@ namespace Tgstation.Server.Host.Components
|
||||
this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
|
||||
this.dotnetDumpService = dotnetDumpService ?? throw new ArgumentNullException(nameof(dotnetDumpService));
|
||||
this.metricFactory = metricFactory ?? throw new ArgumentNullException(nameof(metricFactory));
|
||||
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
sessionConfiguration = sessionConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
this.sessionConfigurationOptions = sessionConfigurationOptions ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
}
|
||||
#pragma warning restore CA1502
|
||||
|
||||
@@ -291,10 +291,10 @@ namespace Tgstation.Server.Host.Components
|
||||
postWriteHandler,
|
||||
platformIdentifier,
|
||||
fileTransferService,
|
||||
generalConfigurationOptions,
|
||||
sessionConfigurationOptions,
|
||||
loggerFactory.CreateLogger<StaticFiles.Configuration>(),
|
||||
metadata,
|
||||
generalConfiguration,
|
||||
sessionConfiguration);
|
||||
metadata);
|
||||
var eventConsumer = new EventConsumer(configuration);
|
||||
var repoManager = repositoryManagerFactory.CreateRepositoryManager(repoIoManager, eventConsumer);
|
||||
try
|
||||
@@ -347,8 +347,8 @@ namespace Tgstation.Server.Host.Components
|
||||
dotnetDumpService,
|
||||
metricFactory,
|
||||
loggerFactory,
|
||||
sessionConfigurationOptions,
|
||||
loggerFactory.CreateLogger<SessionControllerFactory>(),
|
||||
sessionConfiguration,
|
||||
metadata);
|
||||
|
||||
var watchdog = watchdogFactory.CreateWatchdog(
|
||||
@@ -382,8 +382,8 @@ namespace Tgstation.Server.Host.Components
|
||||
remoteDeploymentManagerFactory,
|
||||
asyncDelayer,
|
||||
metricFactory,
|
||||
sessionConfigurationOptions,
|
||||
loggerFactory.CreateLogger<DreamMaker>(),
|
||||
sessionConfiguration,
|
||||
metadata);
|
||||
|
||||
instance = new Instance(
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Prometheus;
|
||||
|
||||
@@ -119,16 +120,16 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// </summary>
|
||||
readonly ILoggerFactory loggerFactory;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="SessionConfiguration"/> for the <see cref="SessionControllerFactory"/>.
|
||||
/// </summary>
|
||||
readonly IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ILogger"/> for the <see cref="SessionControllerFactory"/>.
|
||||
/// </summary>
|
||||
readonly ILogger<SessionControllerFactory> logger;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SessionConfiguration"/> for the <see cref="SessionControllerFactory"/>.
|
||||
/// </summary>
|
||||
readonly SessionConfiguration sessionConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// The number of sessions launched.
|
||||
/// </summary>
|
||||
@@ -198,9 +199,9 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
/// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
|
||||
/// <param name="dotnetDumpService">The value of <see cref="dotnetDumpService"/>.</param>
|
||||
/// <param name="metricFactory">The <see cref="IMetricFactory"/> used to create metrics.</param>
|
||||
/// <param name="sessionConfigurationOptions">The value of <see cref="sessionConfigurationOptions"/>.</param>
|
||||
/// <param name="loggerFactory">The value of <see cref="loggerFactory"/>.</param>
|
||||
/// <param name="logger">The value of <see cref="logger"/>.</param>
|
||||
/// <param name="sessionConfiguration">The value of <see cref="sessionConfiguration"/>.</param>
|
||||
public SessionControllerFactory(
|
||||
IProcessExecutor processExecutor,
|
||||
IEngineManager engineManager,
|
||||
@@ -219,8 +220,8 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
IDotnetDumpService dotnetDumpService,
|
||||
IMetricFactory metricFactory,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions,
|
||||
ILogger<SessionControllerFactory> logger,
|
||||
SessionConfiguration sessionConfiguration,
|
||||
Api.Models.Instance instance)
|
||||
{
|
||||
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
|
||||
@@ -239,9 +240,9 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
|
||||
this.dotnetDumpService = dotnetDumpService ?? throw new ArgumentNullException(nameof(dotnetDumpService));
|
||||
ArgumentNullException.ThrowIfNull(metricFactory);
|
||||
this.sessionConfigurationOptions = sessionConfigurationOptions ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
this.sessionConfiguration = sessionConfiguration ?? throw new ArgumentNullException(nameof(sessionConfiguration));
|
||||
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
|
||||
|
||||
sessionsLaunched = metricFactory.CreateCounter("tgs_sessions_launched", "The number of game server processes created");
|
||||
@@ -567,6 +568,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
|
||||
try
|
||||
{
|
||||
var sessionConfiguration = sessionConfigurationOptions.CurrentValue;
|
||||
if (!apiValidate)
|
||||
{
|
||||
if (sessionConfiguration.HighPriorityLiveDreamDaemon)
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Models.Response;
|
||||
@@ -119,6 +120,16 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// </summary>>
|
||||
readonly IFileTransferTicketProvider fileTransferService;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="GeneralConfiguration"/> for <see cref="Configuration"/>.
|
||||
/// </summary>
|
||||
readonly IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="SessionConfiguration"/> for <see cref="Configuration"/>.
|
||||
/// </summary>
|
||||
readonly IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ILogger"/> for <see cref="Configuration"/>.
|
||||
/// </summary>
|
||||
@@ -129,16 +140,6 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// </summary>
|
||||
readonly Models.Instance metadata;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GeneralConfiguration"/> for <see cref="Configuration"/>.
|
||||
/// </summary>
|
||||
readonly GeneralConfiguration generalConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SessionConfiguration"/> for <see cref="Configuration"/>.
|
||||
/// </summary>
|
||||
readonly SessionConfiguration sessionConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SemaphoreSlim"/> for <see cref="Configuration"/>. Also used as a <see langword="lock"/> <see cref="object"/>.
|
||||
/// </summary>
|
||||
@@ -166,8 +167,8 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// <param name="fileTransferService">The value of <see cref="fileTransferService"/>.</param>
|
||||
/// <param name="metadata">The value of <see cref="metadata"/>.</param>
|
||||
/// <param name="logger">The value of <see cref="logger"/>.</param>
|
||||
/// <param name="generalConfiguration">The value of <see cref="generalConfiguration"/>.</param>
|
||||
/// <param name="sessionConfiguration">The value of <see cref="sessionConfiguration"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The value of <see cref="generalConfigurationOptions"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The value of <see cref="sessionConfigurationOptions"/>.</param>
|
||||
public Configuration(
|
||||
IIOManager ioManager,
|
||||
ISynchronousIOManager synchronousIOManager,
|
||||
@@ -176,10 +177,10 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
IPostWriteHandler postWriteHandler,
|
||||
IPlatformIdentifier platformIdentifier,
|
||||
IFileTransferTicketProvider fileTransferService,
|
||||
IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions,
|
||||
ILogger<Configuration> logger,
|
||||
Models.Instance metadata,
|
||||
GeneralConfiguration generalConfiguration,
|
||||
SessionConfiguration sessionConfiguration)
|
||||
Models.Instance metadata)
|
||||
{
|
||||
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
|
||||
this.synchronousIOManager = synchronousIOManager ?? throw new ArgumentNullException(nameof(synchronousIOManager));
|
||||
@@ -188,10 +189,10 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
this.postWriteHandler = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler));
|
||||
this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
|
||||
this.fileTransferService = fileTransferService ?? throw new ArgumentNullException(nameof(fileTransferService));
|
||||
this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
this.sessionConfigurationOptions = sessionConfigurationOptions ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
|
||||
this.generalConfiguration = generalConfiguration ?? throw new ArgumentNullException(nameof(generalConfiguration));
|
||||
this.sessionConfiguration = sessionConfiguration ?? throw new ArgumentNullException(nameof(sessionConfiguration));
|
||||
|
||||
semaphore = new SemaphoreSlim(1, 1);
|
||||
stoppingCts = new CancellationTokenSource();
|
||||
@@ -223,7 +224,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
null,
|
||||
CodeModificationsSubdirectory,
|
||||
destination,
|
||||
generalConfiguration.GetCopyDirectoryTaskThrottle(),
|
||||
generalConfigurationOptions.CurrentValue.GetCopyDirectoryTaskThrottle(),
|
||||
cancellationToken);
|
||||
|
||||
await Task.WhenAll(dmeExistsTask, headFileExistsTask, tailFileExistsTask, copyTask.AsTask());
|
||||
@@ -795,7 +796,8 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
// always execute in serial
|
||||
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken, logger))
|
||||
{
|
||||
var directories = generalConfiguration.AdditionalEventScriptsDirectories?.ToList() ?? new List<string>();
|
||||
var sessionConfiguration = sessionConfigurationOptions.CurrentValue;
|
||||
var directories = generalConfigurationOptions.CurrentValue.AdditionalEventScriptsDirectories?.ToList() ?? new List<string>();
|
||||
directories.Add(EventScriptsSubdirectory);
|
||||
|
||||
var allScripts = new List<string>();
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Moq;
|
||||
@@ -56,13 +57,13 @@ namespace Tgstation.Server.Host.Components.StaticFiles.Tests
|
||||
Mock.Of<IPostWriteHandler>(),
|
||||
Mock.Of<IPlatformIdentifier>(),
|
||||
Mock.Of<IFileTransferTicketProvider>(),
|
||||
Mock.Of<IOptionsMonitor<GeneralConfiguration>>(),
|
||||
Mock.Of<IOptionsMonitor<SessionConfiguration>>(),
|
||||
loggerFactory.CreateLogger<Configuration>(),
|
||||
new Models.Instance
|
||||
{
|
||||
Path = "Some path",
|
||||
},
|
||||
new GeneralConfiguration(),
|
||||
new SessionConfiguration());
|
||||
});
|
||||
|
||||
await configuration.StartAsync(CancellationToken.None);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user