@@ -149,9 +149,9 @@ private void Build()
149149 {
150150 _client . DefaultRequestHeaders . Authorization
151151 = new AuthenticationHeaderValue ( "Basic" ,
152- Convert . ToBase64String (
153- Encoding . ASCII . GetBytes (
154- $ "{ Options . username } :{ Options . password } ") ) ) ;
152+ Convert . ToBase64String (
153+ Encoding . ASCII . GetBytes (
154+ $ "{ Options . username } :{ Options . password } ") ) ) ;
155155 }
156156 else if ( ! string . IsNullOrEmpty ( Options . token ) )
157157 {
@@ -223,17 +223,14 @@ private CancellationTokenSource GenerateRequestCts(CancellationToken ct = defaul
223223 return cts ;
224224 }
225225
226- /// <summary>
227- /// Creates a new HTTP request with appropriate encoding.
228- /// </summary>
229226 /// <summary>
230227 /// Create an HTTP POST request targeting "/write" with the sender's buffer as the request body.
231228 /// </summary>
232229 /// <returns>An <see cref="HttpRequestMessage"/> configured with the buffer as the request body, Content-Type set to "text/plain" with charset "utf-8", and Content-Length set to the buffer length.</returns>
233230 private HttpRequestMessage GenerateRequest ( )
234231 {
235232 var request = new HttpRequestMessage ( HttpMethod . Post , "/write" )
236- { Content = new BufferStreamContent ( Buffer ) , } ;
233+ { Content = new BufferStreamContent ( Buffer ) , } ;
237234 request . Content . Headers . ContentType = new MediaTypeHeaderValue ( "text/plain" ) { CharSet = "utf-8" , } ;
238235 request . Content . Headers . ContentLength = Buffer . Length ;
239236 return request ;
@@ -260,21 +257,20 @@ public override ISender Transaction(ReadOnlySpan<char> tableName)
260257 if ( WithinTransaction )
261258 {
262259 throw new IngressError ( ErrorCode . InvalidApiCall ,
263- "Cannot start another transaction - only one allowed at a time." ) ;
260+ "Cannot start another transaction - only one allowed at a time." ) ;
264261 }
265262
266263 if ( Length > 0 )
267264 {
268265 throw new IngressError ( ErrorCode . InvalidApiCall ,
269- "Buffer must be clear before you can start a transaction." ) ;
266+ "Buffer must be clear before you can start a transaction." ) ;
270267 }
271268
272269 Buffer . Transaction ( tableName ) ;
273270 return this ;
274271 }
275272
276273 /// <inheritdoc cref="CommitAsync" />
277- /// />
278274 public override void Commit ( CancellationToken ct = default )
279275 {
280276 try
@@ -396,7 +392,8 @@ public override void Send(CancellationToken ct = default)
396392 /// <returns>The final <see cref="HttpResponseMessage"/> returned by the server for a successful request.</returns>
397393 /// <exception cref="IngressError">Thrown with <see cref="ErrorCode.ServerFlushError"/> when a connection could not be established within the allowed retries.</exception>
398394 /// <remarks>The caller is responsible for disposing the returned <see cref="HttpResponseMessage"/>./// </remarks>
399- private HttpResponseMessage SendWithRetries ( CancellationToken ct , Func < HttpRequestMessage > requestFactory , TimeSpan retryTimeout )
395+ private HttpResponseMessage SendWithRetries ( CancellationToken ct , Func < HttpRequestMessage > requestFactory ,
396+ TimeSpan retryTimeout )
400397 {
401398 HttpResponseMessage ? response = null ;
402399 CancellationTokenSource cts = GenerateRequestCts ( ct ) ;
@@ -414,9 +411,9 @@ private HttpResponseMessage SendWithRetries(CancellationToken ct, Func<HttpReque
414411 }
415412
416413 if ( retryTimeout > TimeSpan . Zero )
417- // retry if appropriate - error that's retriable, and retries are enabled
414+ // retry if appropriate - error that's retriable, and retries are enabled
418415 {
419- if ( response == null // if it was a cannot correct error
416+ if ( response == null // if it was a cannot correct error
420417 || ( ! response . IsSuccessStatusCode // or some other http error
421418 && IsRetriableError ( response . StatusCode ) ) )
422419 {
@@ -426,9 +423,9 @@ private HttpResponseMessage SendWithRetries(CancellationToken ct, Func<HttpReque
426423
427424 while ( retryTimer . Elapsed < retryTimeout // whilst we can still retry
428425 && (
429- response == null || // either we can't connect
430- ( ! response . IsSuccessStatusCode && // or we have another http error
431- IsRetriableError ( response . StatusCode ) ) )
426+ response == null || // either we can't connect
427+ ( ! response . IsSuccessStatusCode && // or we have another http error
428+ IsRetriableError ( response . StatusCode ) ) )
432429 )
433430 {
434431 retryInterval = TimeSpan . FromMilliseconds ( Math . Min ( retryInterval . TotalMilliseconds * 2 , 1000 ) ) ;
@@ -460,7 +457,7 @@ private HttpResponseMessage SendWithRetries(CancellationToken ct, Func<HttpReque
460457 if ( response == null )
461458 {
462459 throw new IngressError ( ErrorCode . ServerFlushError ,
463- $ "Cannot connect to `{ Options . Host } :{ Options . Port } `") ;
460+ $ "Cannot connect to `{ Options . Host } :{ Options . Port } `") ;
464461 }
465462
466463 return response ;
@@ -542,7 +539,7 @@ public override async Task SendAsync(CancellationToken ct = default)
542539 // retry if appropriate - error that's retriable, and retries are enabled
543540 if ( Options . retry_timeout > TimeSpan . Zero )
544541 {
545- if ( response == null // if it was a cannot correct error
542+ if ( response == null // if it was a cannot correct error
546543 || ( ! response . IsSuccessStatusCode // or some other http error
547544 && IsRetriableError ( response . StatusCode ) ) )
548545 {
@@ -552,9 +549,9 @@ public override async Task SendAsync(CancellationToken ct = default)
552549
553550 while ( retryTimer . Elapsed < Options . retry_timeout // whilst we can still retry
554551 && (
555- response == null || // either we can't connect
556- ( ! response . IsSuccessStatusCode && // or we have another http error
557- IsRetriableError ( response . StatusCode ) ) )
552+ response == null || // either we can't connect
553+ ( ! response . IsSuccessStatusCode && // or we have another http error
554+ IsRetriableError ( response . StatusCode ) ) )
558555 )
559556 {
560557 retryInterval = TimeSpan . FromMilliseconds ( Math . Min ( retryInterval . TotalMilliseconds * 2 , 1000 ) ) ;
@@ -574,7 +571,7 @@ public override async Task SendAsync(CancellationToken ct = default)
574571 try
575572 {
576573 response = await _client . SendAsync ( request , HttpCompletionOption . ResponseHeadersRead ,
577- cts . Token ) ;
574+ cts . Token ) ;
578575 }
579576 catch ( HttpRequestException )
580577 {
@@ -588,7 +585,7 @@ public override async Task SendAsync(CancellationToken ct = default)
588585 if ( response == null )
589586 {
590587 throw new IngressError ( ErrorCode . ServerFlushError ,
591- $ "Cannot connect to `{ Options . Host } :{ Options . Port } `") ;
588+ $ "Cannot connect to `{ Options . Host } :{ Options . Port } `") ;
592589 }
593590
594591 // return if ok
0 commit comments