diff --git a/src/Tgstation.Server.Client/Components/IByondClient.cs b/src/Tgstation.Server.Client/Components/IByondClient.cs index 76291f4347..2c9ca74652 100644 --- a/src/Tgstation.Server.Client/Components/IByondClient.cs +++ b/src/Tgstation.Server.Client/Components/IByondClient.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Client.Rights; @@ -13,21 +14,24 @@ namespace Tgstation.Server.Client.Components /// /// Gets the current status of any BYOND updates /// + /// The for the operation /// A resulting in the updater - Task CurrentStatus(); + Task CurrentStatus(CancellationToken cancellationToken); /// /// Updates the installed BYOND /// /// The to update to. Only considers the and numbers + /// The for the operation /// A representing the running operation - Task UpdateToVersion(Version version); + Task UpdateToVersion(Version version, CancellationToken cancellationToken); /// /// Get the currently installed BYOND /// /// Read the staged instead if applicable + /// The for the operation /// A resulting in the installed BYOND version or if none is installed - Task GetVersion(bool staged); + Task GetVersion(bool staged, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs b/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs index 64cfd74760..f615eaa389 100644 --- a/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs +++ b/src/Tgstation.Server.Client/Components/IInstanceManagerClient.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Client.Rights; @@ -13,28 +14,32 @@ namespace Tgstation.Server.Client.Components /// /// Get all s for s that the can view /// + /// The for the operation /// A resulting in a of s - Task> GetInstanceClients(); + Task> GetInstanceClients(CancellationToken cancellationToken); /// /// Create an /// /// The to create. will be ignored + /// The for the operation /// A resulting in for the created - Task CreateInstance(Instance instance); + Task CreateInstance(Instance instance, CancellationToken cancellationToken); /// /// Relocates, renamed, and/or on/offlines an /// /// The to update + /// The for the operation /// A representing the running operation - Task UpdateInstance(Instance instance); + Task UpdateInstance(Instance instance, CancellationToken cancellationToken); /// /// Deletes an /// /// The to delete + /// The for the operation /// A representing the running operation - Task DeleteInstance(Instance instance); + Task DeleteInstance(Instance instance, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Client/Components/ITokenClient.cs b/src/Tgstation.Server.Client/Components/ITokenClient.cs index 45e30b9791..7365fedf11 100644 --- a/src/Tgstation.Server.Client/Components/ITokenClient.cs +++ b/src/Tgstation.Server.Client/Components/ITokenClient.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Client.Rights; @@ -13,38 +14,44 @@ namespace Tgstation.Server.Client.Components /// /// Generates a new token for the 's /// + /// The for the operation /// A resulting in a new for the - Task Generate(); + Task Generate(CancellationToken cancellationToken); /// /// Gets all active s for the /// + /// The for the operation /// A resulting a of active s for the - Task> GetClientInfos(); + Task> GetClientInfos(CancellationToken cancellationToken); /// /// Gets all active s for all users /// + /// The for the operation /// A resulting a of active s for the keyed by username - Task> GetAllInfos(); + Task> GetAllInfos(CancellationToken cancellationToken); /// /// Invalidate the specified active designated by /// /// The of the to invalidate + /// The for the operation /// A representing the running operation - Task Invalidate(long tokenId); + Task Invalidate(long tokenId, CancellationToken cancellationToken); /// /// Invalidate all active s for a /// + /// The for the operation /// A representing the running operation - Task InvalidateAllClient(); + Task InvalidateAllClient(CancellationToken cancellationToken); /// /// Invalidate all active s /// + /// The for the operation /// A representing the running operation - Task InvalidateAll(); + Task InvalidateAll(CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Client/IClient.cs b/src/Tgstation.Server.Client/IClient.cs index 3b34351384..2091805d10 100644 --- a/src/Tgstation.Server.Client/IClient.cs +++ b/src/Tgstation.Server.Client/IClient.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Threading; +using System.Threading.Tasks; namespace Tgstation.Server.Client { @@ -21,7 +22,8 @@ namespace Tgstation.Server.Client /// /// Get the for the /// + /// The for the operation /// A resulting in the for the - Task Rights(); + Task Rights(CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Client/IServerClient.cs b/src/Tgstation.Server.Client/IServerClient.cs index c745c793c5..6e1baa11d4 100644 --- a/src/Tgstation.Server.Client/IServerClient.cs +++ b/src/Tgstation.Server.Client/IServerClient.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Client.Components; using Tgstation.Server.Client.Rights; @@ -31,6 +32,6 @@ namespace Tgstation.Server.Client /// /// A resulting in the of the connected server /// Note that if the differs from the 's API functionality will most likely be compromised - Task GetServerVersion(); + Task GetServerVersion(CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Client/IServerClientFactory.cs b/src/Tgstation.Server.Client/IServerClientFactory.cs index 710f32aa76..fb79446eb0 100644 --- a/src/Tgstation.Server.Client/IServerClientFactory.cs +++ b/src/Tgstation.Server.Client/IServerClientFactory.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Threading; +using System.Threading.Tasks; namespace Tgstation.Server.Client { @@ -13,10 +14,11 @@ namespace Tgstation.Server.Client /// The URL to access tgstation-server at /// The username to for the /// The password for the - /// The initial timeout for the connection + /// The initial timeout for the connection in milliseconds + /// The for the operation /// A resulting in a new /// If the and/or is invalid - Task CreateServerClient(string hostname, string username, string password, int timeout = 10000); + Task CreateServerClient(string hostname, string username, string password, int timeout, CancellationToken cancellationToken); /// /// Create a @@ -24,8 +26,9 @@ namespace Tgstation.Server.Client /// The URL to access tgstation-server at /// The to access the API with /// The initial timeout for the connection + /// The for the operation /// A resulting in a new /// If the invalid - Task CreateServerClient(string hostname, string token, int timeout = 10000); + Task CreateServerClient(string hostname, string token, int timeout, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Client/ServerClientFactory.cs b/src/Tgstation.Server.Client/ServerClientFactory.cs index d54f2211b0..1d4af06329 100644 --- a/src/Tgstation.Server.Client/ServerClientFactory.cs +++ b/src/Tgstation.Server.Client/ServerClientFactory.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; namespace Tgstation.Server.Client @@ -7,9 +8,9 @@ namespace Tgstation.Server.Client public sealed class ServerClientFactory : IServerClientFactory { /// - public Task CreateServerClient(string hostname, string username, string password, int timeout = 10000) => throw new NotImplementedException(); + public Task CreateServerClient(string hostname, string username, string password, int timeout, CancellationToken cancellationToken) => throw new NotImplementedException(); /// - public Task CreateServerClient(string hostname, string token, int timeout = 10000) => throw new NotImplementedException(); + public Task CreateServerClient(string hostname, string token, int timeout, CancellationToken cancellationToken) => throw new NotImplementedException(); } } diff --git a/tests/Tgstation.Server.Client.Tests/TestServerClientFactory.cs b/tests/Tgstation.Server.Client.Tests/TestServerClientFactory.cs index 6b5f203e6b..981ce7295e 100644 --- a/tests/Tgstation.Server.Client.Tests/TestServerClientFactory.cs +++ b/tests/Tgstation.Server.Client.Tests/TestServerClientFactory.cs @@ -14,14 +14,14 @@ namespace Tgstation.Server.Client.Tests public async Task TestUserConstruction() { var factory = new ServerClientFactory(); - await Assert.ThrowsExceptionAsync(() => factory.CreateServerClient(null, null, null)).ConfigureAwait(false); + await Assert.ThrowsExceptionAsync(() => factory.CreateServerClient(null, null, null, default, default)).ConfigureAwait(false); } [TestMethod] public async Task TestTokenConstruction() { var factory = new ServerClientFactory(); - await Assert.ThrowsExceptionAsync(() => factory.CreateServerClient(null, null)).ConfigureAwait(false); + await Assert.ThrowsExceptionAsync(() => factory.CreateServerClient(null, null, default, default)).ConfigureAwait(false); } } }