Skip to content

Commit

Permalink
Support backend circuit breakers and load balancers (closes #463).
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Fankam committed Aug 15, 2024
1 parent 3998ee0 commit b9c4361
Showing 1 changed file with 99 additions and 5 deletions.
104 changes: 99 additions & 5 deletions tools/code/common/Backend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public sealed record BackendDto

public record BackendContract
{
[JsonPropertyName("circuitBreaker")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public BackendCircuitBreaker? CircuitBreaker { get; init; }

[JsonPropertyName("credentials")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public BackendCredentialsContract? Credentials { get; init; }
Expand All @@ -137,6 +141,10 @@ public record BackendContract
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? Description { get; init; }

[JsonPropertyName("pool")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Pool? Pool { get; init; }

[JsonPropertyName("properties")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public BackendProperties? Properties { get; init; }
Expand All @@ -161,13 +169,77 @@ public record BackendContract
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public BackendTlsProperties? Tls { get; init; }

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? Type { get; init; }

[JsonPropertyName("url")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
#pragma warning disable CA1056 // URI-like properties should not be strings
public string? Url { get; init; }
#pragma warning restore CA1056 // URI-like properties should not be strings
}

public record BackendCircuitBreaker
{
[JsonPropertyName("rules")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableArray<CircuitBreakerRule>? Rules { get; init; }
}

public record CircuitBreakerRule
{
[JsonPropertyName("acceptRetryAfter")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? AcceptRetryAfter { get; init; }

[JsonPropertyName("failureCondition")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public CircuitBreakerFailureCondition? FailureCondition { get; init; }

[JsonPropertyName("name")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? Name { get; init; }

[JsonPropertyName("tripDuration")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? TripDuration { get; init; }
}

public record CircuitBreakerFailureCondition
{
[JsonPropertyName("count")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? Count { get; init; }

[JsonPropertyName("errorReasons")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableArray<string>? ErrorReasons { get; init; }

[JsonPropertyName("interval")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? Interval { get; init; }

[JsonPropertyName("percentage")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? Percentage { get; init; }

[JsonPropertyName("statusCodeRanges")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableArray<FailureStatusCodeRange>? StatusCodeRanges { get; init; }
}

public record FailureStatusCodeRange
{
[JsonPropertyName("max")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? Max { get; init; }

[JsonPropertyName("min")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? Min { get; init; }
}

public record BackendCredentialsContract
{
[JsonPropertyName("authorization")]
Expand All @@ -176,11 +248,11 @@ public record BackendCredentialsContract

[JsonPropertyName("certificate")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableList<string>? Certificate { get; init; }
public ImmutableArray<string>? Certificate { get; init; }

[JsonPropertyName("certificateIds")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableList<string>? CertificateIds { get; init; }
public ImmutableArray<string>? CertificateIds { get; init; }

[JsonPropertyName("header")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
Expand Down Expand Up @@ -238,19 +310,41 @@ public record BackendServiceFabricClusterProperties

[JsonPropertyName("managementEndpoints")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableList<string>? ManagementEndpoints { get; init; }
public ImmutableArray<string>? ManagementEndpoints { get; init; }

[JsonPropertyName("maxPartitionResolutionRetries")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? MaxPartitionResolutionRetries { get; init; }

[JsonPropertyName("serverCertificateThumbprints")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableList<string>? ServerCertificateThumbprints { get; init; }
public ImmutableArray<string>? ServerCertificateThumbprints { get; init; }

[JsonPropertyName("serverX509Names")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableList<X509CertificateName>? ServerX509Names { get; init; }
public ImmutableArray<X509CertificateName>? ServerX509Names { get; init; }
}

public record Pool
{
[JsonPropertyName("services")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public ImmutableArray<BackendPoolItem>? Services { get; init; }
}

public record BackendPoolItem
{
[JsonPropertyName("id")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? Id { get; init; }

[JsonPropertyName("priority")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? Priority { get; init; }

[JsonPropertyName("weight")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? Weight { get; init; }
}

public record BackendTlsProperties
Expand Down

0 comments on commit b9c4361

Please sign in to comment.