Skip to content

Commit

Permalink
Refactored code that checks for default hosts when retrying fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Apr 19, 2024
1 parent c2d5739 commit e044c22
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/IO.Ably.Shared/ClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ public string[] FallbackHosts

internal bool IsProductionEnvironment => Environment.IsEmpty() || Environment.Equals("production", StringComparison.OrdinalIgnoreCase);

internal bool IsDefaultRestHost => FullRestHost() == Defaults.RestHost;

internal bool IsDefaultRealtimeHost => FullRealtimeHost() == Defaults.RealtimeHost;

internal bool IsDefaultPort => Tls ? TlsPort == Defaults.TlsPort : Port == Defaults.Port;

/// <summary>
Expand Down
9 changes: 1 addition & 8 deletions src/IO.Ably.Shared/Realtime/AttemptsHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ internal static class AttemptsHelpers
{
public static async Task<bool> CanFallback(this AblyRest restClient, ErrorInfo error)
{
return IsDefaultHost() &&
error != null && error.IsRetryableStatusCode() &&
await restClient.CanConnectToAbly();

bool IsDefaultHost()
{
return restClient.Options.IsDefaultRealtimeHost;
}
return error != null && error.IsRetryableStatusCode() && await restClient.CanConnectToAbly();
}

public static bool ShouldSuspend(this RealtimeState state, Func<DateTimeOffset> now = null)
Expand Down
2 changes: 1 addition & 1 deletion src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public async Task ShouldUseCustomFallbackHostIfProvided()
[Fact]
[Trait("spec", "RSC15a")]
[Trait("spec", "TO3k6")]
public async Task ShouldUseCustomFallbackHostIfProvidedAndDefaultHostIsDifferent()
public async Task ShouldUseProvidedCustomFallbackHostWhenDefaultHostIsDifferent()
{
_response.StatusCode = HttpStatusCode.BadGateway;
var attemptedList = new List<string>();
Expand Down

0 comments on commit e044c22

Please sign in to comment.