-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerRemovalService.cs
More file actions
27 lines (25 loc) · 1.31 KB
/
Copy pathServerRemovalService.cs
File metadata and controls
27 lines (25 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using RustPlusBot.Features.Connections.Supervisor;
using RustPlusBot.Features.Workspace.Teardown;
using RustPlusBot.Persistence.Servers;
namespace RustPlusBot.Features.Connections.Removal;
/// <summary>Default <see cref="IServerRemovalService"/>. Order matters: stop the socket before deleting the row,
/// so no late status write re-inserts a connection-state row against a deleted server (FK violation).</summary>
/// <param name="supervisor">Stops the live socket.</param>
/// <param name="servers">Deletes the RustServer (cascades credentials + connection state).</param>
/// <param name="workspace">Tears down the server's Discord category/channels/records.</param>
internal sealed class ServerRemovalService(
IConnectionSupervisor supervisor,
IServerService servers,
IServerWorkspaceRemover workspace) : IServerRemovalService
{
/// <inheritdoc />
public async Task<bool> RemoveServerAsync(ulong guildId,
Guid serverId,
CancellationToken cancellationToken = default)
{
await supervisor.StopAsync(guildId, serverId).ConfigureAwait(false);
var removed = await servers.RemoveAsync(guildId, serverId, cancellationToken).ConfigureAwait(false);
await workspace.RemoveServerAsync(guildId, serverId, cancellationToken).ConfigureAwait(false);
return removed;
}
}