Updated to latest moonlight and mooncore version. Done refactoring to async scheme and other changes. Recreated database migrations and cleaned models

This commit is contained in:
2025-09-22 12:13:57 +02:00
parent 91fb15a03e
commit 85392208c4
150 changed files with 2722 additions and 2726 deletions

View File

@@ -1,11 +1,6 @@
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using Docker.DotNet;
using Docker.DotNet.Models;
using MoonCore.Events;
using MoonCore.Observability;
using MoonlightServers.Daemon.Helpers;
namespace MoonlightServers.Daemon.Services;

View File

@@ -25,7 +25,7 @@ public class DockerImageService
Logger = logger;
}
public async Task Download(string name, Action<string>? onProgressUpdated = null)
public async Task DownloadAsync(string name, Action<string>? onProgressUpdated = null)
{
// If there is already a download for this image occuring, we want to wait for this to complete instead
// of calling docker to download it again

View File

@@ -17,16 +17,16 @@ public class DockerInfoService
UnsafeDockerClient = unsafeDockerClient;
}
public async Task<string> GetDockerVersion()
public async Task<string> GetDockerVersionAsync()
{
var version = await DockerClient.System.GetVersionAsync();
return $"{version.Version} commit {version.GitCommit} ({version.APIVersion})";
}
public async Task<UsageDataReport> GetDataUsage()
public async Task<UsageDataReport> GetDataUsageAsync()
{
var response = await UnsafeDockerClient.GetDataUsage();
var response = await UnsafeDockerClient.GetDataUsageAsync();
var report = new UsageDataReport()
{

View File

@@ -1,6 +1,3 @@
using System.IdentityModel.Tokens.Jwt;
using System.Text;
using Microsoft.IdentityModel.Tokens;
using MoonCore.Attributes;
using MoonCore.Helpers;
using MoonCore.Models;
@@ -19,26 +16,26 @@ public class RemoteService
ApiClient = CreateHttpClient(configuration);
}
public async Task GetStatus()
public async Task GetStatusAsync()
{
await ApiClient.Get("api/remote/servers/node/trip");
}
public async Task<PagedData<ServerDataResponse>> GetServers(int page, int perPage)
public async Task<CountedData<ServerDataResponse>> GetServersAsync(int startIndex, int count)
{
return await ApiClient.GetJson<PagedData<ServerDataResponse>>(
$"api/remote/servers?page={page}&pageSize={perPage}"
return await ApiClient.GetJson<CountedData<ServerDataResponse>>(
$"api/remote/servers?startIndex={startIndex}&count={count}"
);
}
public async Task<ServerDataResponse> GetServer(int serverId)
public async Task<ServerDataResponse> GetServerAsync(int serverId)
{
return await ApiClient.GetJson<ServerDataResponse>(
$"api/remote/servers/{serverId}"
);
}
public async Task<ServerInstallDataResponse> GetServerInstallation(int serverId)
public async Task<ServerInstallDataResponse> GetServerInstallationAsync(int serverId)
{
return await ApiClient.GetJson<ServerInstallDataResponse>(
$"api/remote/servers/{serverId}/install"

View File

@@ -1,5 +1,4 @@
using System.Collections.Concurrent;
using MoonCore.Helpers;
using MoonCore.Models;
using MoonlightServers.Daemon.Mappers;
using MoonlightServers.Daemon.Models.Cache;
@@ -32,7 +31,7 @@ public class ServerService : IHostedLifecycleService
public Server? GetById(int id)
=> Servers.GetValueOrDefault(id);
public async Task Initialize(ServerConfiguration configuration)
public async Task InitializeAsync(ServerConfiguration configuration)
{
var existingServer = Servers.GetValueOrDefault(configuration.Id);
@@ -50,20 +49,20 @@ public class ServerService : IHostedLifecycleService
}
}
public async Task InitializeById(int id)
public async Task InitializeByIdAsync(int id)
{
var serverData = await RemoteService.GetServer(id);
var serverData = await RemoteService.GetServerAsync(id);
var config = ConfigurationMapper.FromServerDataResponse(serverData);
await Initialize(config);
await InitializeAsync(config);
}
private async Task InitializeAll()
private async Task InitializeAllAsync()
{
Logger.LogDebug("Initialing servers from panel");
var servers = await PagedData<ServerDataResponse>.All(async (page, pageSize) =>
await RemoteService.GetServers(page, pageSize)
var servers = await CountedData<ServerDataResponse>.LoadAllAsync(async (startIndex, count) =>
await RemoteService.GetServersAsync(startIndex, count)
);
foreach (var serverData in servers)
@@ -72,7 +71,7 @@ public class ServerService : IHostedLifecycleService
{
var config = ConfigurationMapper.FromServerDataResponse(serverData);
await Initialize(config);
await InitializeAsync(config);
}
catch (Exception e)
{
@@ -91,7 +90,7 @@ public class ServerService : IHostedLifecycleService
public async Task StartedAsync(CancellationToken cancellationToken)
{
await InitializeAll();
await InitializeAllAsync();
}
public Task StartingAsync(CancellationToken cancellationToken)