Implemented restorer, wired up for basic testing. Improved abstractions and fixed observer pattern issues

This commit is contained in:
2025-07-26 23:19:57 +02:00
parent 84b3d1caf6
commit b546a168d2
17 changed files with 355 additions and 97 deletions

View File

@@ -1,7 +1,5 @@
using MoonlightServers.Daemon.Helpers;
using MoonlightServers.Daemon.Models.Cache;
using MoonlightServers.Daemon.ServerSys.Abstractions;
using MoonlightServers.Daemon.ServerSys.Implementations;
namespace MoonlightServers.Daemon.ServerSys;
@@ -16,24 +14,13 @@ public class ServerFactory
public Server CreateServer(ServerConfiguration configuration)
{
var serverMeta = new ServerMeta();
serverMeta.Configuration = configuration;
// Build service collection
serverMeta.ServiceCollection = new ServiceCollection();
var scope = ServiceProvider.CreateAsyncScope();
// Configure service pipeline for the server components
serverMeta.ServiceCollection.AddSingleton<IConsole, DockerConsole>();
serverMeta.ServiceCollection.AddSingleton<IFileSystem, RawFileSystem>();
var meta = scope.ServiceProvider.GetRequiredService<ServerContext>();
// TODO: Handle implementation configurations (e.g. virtual disk) here
// Combine both app service provider and our server instance specific one
serverMeta.ServiceProvider = new CompositeServiceProvider([
serverMeta.ServiceCollection.BuildServiceProvider(),
ServiceProvider
]);
meta.Configuration = configuration;
meta.ServiceScope = scope;
return serverMeta.ServiceProvider.GetRequiredService<Server>();
return scope.ServiceProvider.GetRequiredService<Server>();
}
}