Merge pull request #1483 from tgstation/NitsAndShit

Minorest of changes
This commit is contained in:
Jordan Dominion
2023-04-30 20:07:31 -04:00
committed by GitHub
8 changed files with 22 additions and 13 deletions
@@ -18,8 +18,6 @@ Each of these is tied under the roof of an [IInstance](./IInstance.cs) ([impleme
While the database represents stored instance data, in component code an instance is online, or doesn't exist.
`IInstance`s are created via the [IInstanceFactory](./IInstanceFactory.cs) ([implementation](./InstanceFactory.cs)) and are generally controlled via the [IInstanceManager](./IInstanceManager.cs) ([implementation](./InstanceManager.cs)).
`IInstance`s ([implementation](./Instance.cs)) are created via the [IInstanceFactory](./IInstanceFactory.cs) ([implementation](./InstanceFactory.cs)) and are generally controlled via the [IInstanceOperations](./IInstanceOperations.cs) interface (implemented in the `InstanceManager`).
Many classes in here implement [IHostedService](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-6.0&tabs=visual-studio), `InstanceManager` being the only one that is called by the ASP.NET runtime. In the case of instances `StartAsync()` is called when an `Instance` is being brought online (from server startup or user request). The `Instance` handles calling `StartAsync()` on its various subcomponents that need it. When an `Instance` is being brought offline (from server shutdown/restart/update or user request) the same pattern is followed calling `StopAsync()`.
`IInstanceManager` is the sole point where the controllers talk to component code. It also dispatches bridge requests to their relevant instances.
+5 -8
View File
@@ -1,13 +1,10 @@
# Core Services
This is a bag of classes used throughout TGS that don't quite belong anywhere else.
- [Application](./Application.cs) is our main [composition root](https://freecontent.manning.com/dependency-injection-in-net-2nd-edition-understanding-the-composition-root/).
- [IAsyncDelayer](./IAsyncDelayer.cs) and [implementation](./AsyncDelayer.cs) is a class used to sleep code. It's generally a no-op in test scenarios.
- [IGitHubClientFactory](./IGitHubClientFactory.cs) and [implementation](./GitHubClientFactory.cs) is a class used to create GitHub API clients using [ocktokit.net](https://github.com/octokit/octokit.net).
- [IRestartHandler](./IRestartHandler.cs) and [IRestartRegistration](./IRestartRegistration.cs) are a set of interface services use when they want to be aware of a TGS restart/update (i.e. This is how the watchdog know to detach instead of shutdown).
- [IServerControl](./IServerControl.cs) is an interface used to initiate a restart or update the server.
- [IServerControl](./IServerControl.cs) is an interface used to initiate a restart, shutdown, or update the server.
- [IServerPortProvider](./IServerPortProvider.cs) and [implementation](./ServerPortProvider.cs) is used by services to determine the local TGS API port. Used mainly for telling DreamDaemon where to make bridge requests.
- [OpenApiEnumVarNamesExtension](./OpenApiEnumVarNamesExtension) implements the [x-var-names OpenAPI 3.0 extension](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md#enum) in our generated API json.
- [SemaphoreSlimContext](./SemaphoreSlimContext.cs) is a helper class for working with [.NET asynchronous sempahores](https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=netcore-6.0).
- [SwaggerConfiguration](./SwaggerConfiguration.cs) configures [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) to generate our OpenAPI specification.
- [IServerUpdater](./IServerUpdater.cs), [IServerUpdateExecutor](./IServerUpdateExecutor.cs) and their implementation [implementation](./ServerUpdater.cs) handles the process of downloading and unzipping update packages while respecting the Swarm protocol.
- [IServerUpdateInitiator](./IServerUpdateInitiator.cs) and [implementation](./ServerUpdateInitiator.cs) handles bridging the gap between the Controllers and the update process.
- [ServerUpdateOperation](./ServerUpdateOperation.cs) is a utility struct used by the update process.
- [ServerUpdateResult](./ServerUpdateOperation.cs) is an enumeration that indicates the result of trying to start an update operation.
@@ -4,6 +4,7 @@ using System.Threading;
using System.Threading.Tasks;
using BetterWin32Errors;
using Tgstation.Server.Host.System;
namespace Tgstation.Server.Host.IO
{
+3 -1
View File
@@ -27,7 +27,7 @@ Here's a breakdown of things in this directory
- [Components](./Components) is where the bulk of the TGS implementation lives.
- [Configuration](./Configuration) contains classes that partly make up the configuration yaml files (i.e. [appsettings.yml](./appsettings.yml)).
- [Controllers](./Controllers) is where HTTP API code lives and bridges it with component code.
- [Core](./Core) contains [Application.cs](./Core/Application.cs) and other various helpers that don't belong anywhere else.
- [Core](./Core) contains [Application.cs](./Core/Application.cs) and other classes related to the overrarching server process.
- [Database](./Database) contains all database related code.
- [Extensions](./Extensions) contains helper functions implemented as C# extension methods.
- [IO](./IO) contains classes related to interacting with the filesystem.
@@ -36,6 +36,8 @@ Here's a breakdown of things in this directory
- [Properties](./Properties) contains some assembly metadata, mainly used to expose internals to the testing suite.
- [Security](./Security) contains all the security related classes.
- [Setup](./Setup) contains code to initiate and run the setup wizard.
- [Swarm](./Swarm) contains code relating to grouping multiple TGS processes on different machines in a cohesive cluster.
- [System](./System) contains various OS related functions.
- [Utils](./Utils) contains various helpers that don't belong anywhere else.
As a final note, all project configuration is of course in the [Tgstation.Server.Host.csproj](./Tgstation.Server.Host.csproj) file. This contains package references that are pulled in on build, as well as other things like global warning supressions, and specialized build scripts.
@@ -10,6 +10,7 @@ using Microsoft.Win32.SafeHandles;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Models;
using Tgstation.Server.Host.System;
namespace Tgstation.Server.Host.Security
{
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
using System.Text;
namespace Tgstation.Server.Host
namespace Tgstation.Server.Host.System
{
/// <summary>
/// Native Windows methods used by the code.
@@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Jobs;
using Tgstation.Server.Host.System;
namespace Tgstation.Server.Host.System
{
@@ -0,0 +1,9 @@
# Util classes
This is a bag of classes used throughout TGS that don't quite belong anywhere else.
- [IAsyncDelayer](./IAsyncDelayer.cs) and [implementation](./AsyncDelayer.cs) is a class used to sleep code. It's generally a no-op in test scenarios.
- [IGitHubClientFactory](./IGitHubClientFactory.cs) and [implementation](./GitHubClientFactory.cs) is a class used to create GitHub API clients using [ocktokit.net](https://github.com/octokit/octokit.net).
- [OpenApiEnumVarNamesExtension](./OpenApiEnumVarNamesExtension) implements the [x-var-names OpenAPI 3.0 extension](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/templating.md#enum) in our generated API json.
- [SemaphoreSlimContext](./SemaphoreSlimContext.cs) is a helper class for working with [.NET asynchronous sempahores](https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=netcore-6.0).
- [SwaggerConfiguration](./SwaggerConfiguration.cs) configures [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) to generate our OpenAPI specification.