Skip to content

Commit

Permalink
docs: Add RetryHandler remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Dec 6, 2023
1 parent 8f789e1 commit bee9f0a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Testcontainers.Couchbase/CouchbaseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,15 +541,29 @@ public CreateBucketRequest(CouchbaseBucket bucket)
}
}

/// <summary>
/// An HTTP retry handler that sends an HTTP request until it succeeds.
/// </summary>
/// <remarks>
/// Sending an HTTP request to Couchbase's API sometimes fails with the following
/// error: System.Net.Http.HttpIOException: The response ended prematurely (ResponseEnded).
/// The HTTP status code 504 indicates an issue with the Couchbase backend.
/// It is likely that the API is not yet ready to process HTTP requests.
/// Typically, trying it again resolves the issue.
/// </remarks>
private sealed class RetryHandler : DelegatingHandler
{
private const int MaxRetries = 5;

/// <summary>
/// Initializes a new instance of the <see cref="RetryHandler" /> class.
/// </summary>
public RetryHandler()
: base(new HttpClientHandler())
{
}

/// <inheritdoc />
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
for (var _ = 0; _ < MaxRetries; _++)
Expand Down

0 comments on commit bee9f0a

Please sign in to comment.