-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1698 from tgstation/Day0Fixes [TGSDeploy][NugetDe…
…ploy] v5.17.1 Fixes
- Loading branch information
Showing
8 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<!-- This is in it's own file to help incremental building, changing it causes a complete rebuild of the web panel --> | ||
<TgsControlPanelVersion>4.26.0</TgsControlPanelVersion> | ||
<TgsControlPanelVersion>4.26.2</TgsControlPanelVersion> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Tgstation.Server.Client/ApiClientTokenRefreshRetryPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Threading; | ||
|
||
using Microsoft.AspNetCore.SignalR.Client; | ||
|
||
namespace Tgstation.Server.Client | ||
{ | ||
/// <summary> | ||
/// A <see cref="IRetryPolicy"/> that attempts to refresh a given <see cref="apiClient"/>'s token on the first disconnect. | ||
/// </summary> | ||
sealed class ApiClientTokenRefreshRetryPolicy : IRetryPolicy | ||
{ | ||
/// <summary> | ||
/// The backing <see cref="ApiClient"/>. | ||
/// </summary> | ||
readonly ApiClient apiClient; | ||
|
||
/// <summary> | ||
/// The wrapped <see cref="IRetryPolicy"/>. | ||
/// </summary> | ||
readonly IRetryPolicy wrappedPolicy; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ApiClientTokenRefreshRetryPolicy"/> class. | ||
/// </summary> | ||
/// <param name="apiClient">The value of <see cref="apiClient"/>.</param> | ||
/// <param name="wrappedPolicy">The value of <see cref="wrappedPolicy"/>.</param> | ||
public ApiClientTokenRefreshRetryPolicy(ApiClient apiClient, IRetryPolicy wrappedPolicy) | ||
{ | ||
this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); | ||
this.wrappedPolicy = wrappedPolicy ?? throw new ArgumentNullException(nameof(wrappedPolicy)); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public TimeSpan? NextRetryDelay(RetryContext retryContext) | ||
{ | ||
if (retryContext == null) | ||
throw new ArgumentNullException(nameof(retryContext)); | ||
|
||
if (retryContext.PreviousRetryCount == 0) | ||
AttemptTokenRefresh(); | ||
|
||
return wrappedPolicy.NextRetryDelay(retryContext); | ||
} | ||
|
||
/// <summary> | ||
/// Attempt to refresh the <see cref="apiClient"/>s token asynchronously. | ||
/// </summary> | ||
async void AttemptTokenRefresh() | ||
{ | ||
try | ||
{ | ||
await apiClient.RefreshToken(CancellationToken.None); | ||
} | ||
catch | ||
{ | ||
// intentionally ignored | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters