Skip to content

[Backport 8.0] Update to Elastic.Transport 0.4.2 #6959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/Benchmarks/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -1195,7 +1195,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Profiling/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -131,7 +131,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -143,7 +143,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
},
Expand Down Expand Up @@ -183,8 +183,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -332,7 +332,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
},
Expand Down Expand Up @@ -381,8 +381,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -529,7 +529,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
},
Expand Down Expand Up @@ -569,8 +569,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -709,7 +709,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
},
Expand Down Expand Up @@ -749,8 +749,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -849,7 +849,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
},
Expand Down Expand Up @@ -889,8 +889,8 @@
},
"Elastic.Transport": {
"type": "Transitive",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -989,7 +989,7 @@
"elastic.clients.elasticsearch": {
"type": "Project",
"dependencies": {
"Elastic.Transport": "[0.4.0, )"
"Elastic.Transport": "[0.4.2, )"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Clients.Elasticsearch/Api/BulkResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class BulkResponse
? Enumerable.Empty<ResponseItem>()
: Items.Where(i => !i.IsValid);

public override bool IsValid => base.IsValid && !Errors && !ItemsWithErrors.HasAny();
public override bool IsValidResponse => base.IsValidResponse && !Errors && !ItemsWithErrors.HasAny();

protected override void DebugIsValid(StringBuilder sb)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ namespace Elastic.Clients.Elasticsearch;

public static class ElasticsearchResponseExtensions
{
public static bool IsSuccess(this ElasticsearchResponse response) => response.ApiCallDetails is not null && response.ApiCallDetails.Success;
public static bool IsSuccess(this ElasticsearchResponse response) => response.ApiCallDetails is not null && response.ApiCallDetails.HasSuccessfulStatusCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ElasticsearchClientProductRegistration(Type markerType) : base(markerType
public static ElasticsearchClientProductRegistration DefaultForElasticsearchClientsElasticsearch { get; } = new(typeof(ElasticsearchClient));

/// <summary>
/// Elastic.Clients.Elasticsearch handles 404 in its <see cref="ElasticsearchResponse.IsValid" />, we do not want the low level client throwing
/// Elastic.Clients.Elasticsearch handles 404 in its <see cref="ElasticsearchResponse.IsValidResponse" />, we do not want the low level client throwing
/// exceptions
/// when <see cref="ITransportConfiguration.ThrowExceptions" /> is enabled for 404's. The client is in charge of
/// composing paths
Expand All @@ -33,7 +33,7 @@ public override bool TryGetServerErrorReason<TResponse>(TResponse response, [Not
{
if (response is not ElasticsearchResponse r)
return base.TryGetServerErrorReason(response, out reason);
reason = r.ServerError?.Error?.ToString();
reason = r.ElasticsearchServerError?.Error?.ToString();
return !string.IsNullOrEmpty(reason);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Nullable>annotations</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Elastic.Transport" Version="0.4.0" />
<PackageReference Include="Elastic.Transport" Version="0.4.2" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.3.44">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void RefreshOnCompleted()

var refresh = _client.Indices.Refresh(request);

if (!refresh.IsValid)
if (!refresh.IsValidResponse)
throw Throw($"Refreshing after all documents have indexed failed", refresh);
}

Expand Down Expand Up @@ -155,7 +155,7 @@ private async Task<BulkAllResponse> BulkAsync(IList<T> buffer, long page, int ba
_compositeCancelToken.ThrowIfCancellationRequested();
_bulkResponseCallback?.Invoke(response);

if (!response.ApiCallDetails.Success)
if (!response.ApiCallDetails.HasSuccessfulStatusCode)
return await HandleBulkRequestAsync(buffer, page, backOffRetries, response).ConfigureAwait(false);

var retryableDocuments = new List<T>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Elastic.Clients.Elasticsearch;

public partial class MultiSearchResponse<TDocument>
{
public override bool IsValid => base.IsValid && (Responses?.All(b => b.Item1 is not null && b.Item1.Status == 200) ?? true);
public override bool IsValidResponse => base.IsValidResponse && (Responses?.All(b => b.Item1 is not null && b.Item1.Status == 200) ?? true);

[JsonIgnore]
public int TotalResponses => Responses.HasAny() ? Responses.Count() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
namespace Elastic.Clients.Elasticsearch;
public sealed partial class ExistsResponse : ElasticsearchResponse
{
public bool Exists => ApiCallDetails is { Success: true, HttpStatusCode: 200 };
public bool Exists => ApiCallDetails is { HasSuccessfulStatusCode: true, HttpStatusCode: 200 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
namespace Elastic.Clients.Elasticsearch;
public sealed partial class ExistsSourceResponse : ElasticsearchResponse
{
public bool Exists => ApiCallDetails is { Success: true, HttpStatusCode: 200 };
public bool Exists => ApiCallDetails is { HasSuccessfulStatusCode: true, HttpStatusCode: 200 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
namespace Elastic.Clients.Elasticsearch.IndexManagement;
public sealed partial class ExistsAliasResponse : ElasticsearchResponse
{
public bool Exists => ApiCallDetails is { Success: true, HttpStatusCode: 200 };
public bool Exists => ApiCallDetails is { HasSuccessfulStatusCode: true, HttpStatusCode: 200 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
namespace Elastic.Clients.Elasticsearch.IndexManagement;
public sealed partial class ExistsIndexTemplateResponse : ElasticsearchResponse
{
public bool Exists => ApiCallDetails is { Success: true, HttpStatusCode: 200 };
public bool Exists => ApiCallDetails is { HasSuccessfulStatusCode: true, HttpStatusCode: 200 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
namespace Elastic.Clients.Elasticsearch.IndexManagement;
public sealed partial class ExistsResponse : ElasticsearchResponse
{
public bool Exists => ApiCallDetails is { Success: true, HttpStatusCode: 200 };
public bool Exists => ApiCallDetails is { HasSuccessfulStatusCode: true, HttpStatusCode: 200 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
namespace Elastic.Clients.Elasticsearch.IndexManagement;
public sealed partial class ExistsTemplateResponse : ElasticsearchResponse
{
public bool Exists => ApiCallDetails is { Success: true, HttpStatusCode: 200 };
public bool Exists => ApiCallDetails is { HasSuccessfulStatusCode: true, HttpStatusCode: 200 };
}
36 changes: 18 additions & 18 deletions src/Elastic.Clients.Elasticsearch/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"Elastic.Transport": {
"type": "Direct",
"requested": "[0.4.0, )",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"requested": "[0.4.2, )",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -163,9 +163,9 @@
},
"Elastic.Transport": {
"type": "Direct",
"requested": "[0.4.0, )",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"requested": "[0.4.2, )",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -347,9 +347,9 @@
},
"Elastic.Transport": {
"type": "Direct",
"requested": "[0.4.0, )",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"requested": "[0.4.2, )",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -539,9 +539,9 @@
},
"Elastic.Transport": {
"type": "Direct",
"requested": "[0.4.0, )",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"requested": "[0.4.2, )",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -714,9 +714,9 @@
},
"Elastic.Transport": {
"type": "Direct",
"requested": "[0.4.0, )",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"requested": "[0.4.2, )",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -849,9 +849,9 @@
},
"Elastic.Transport": {
"type": "Direct",
"requested": "[0.4.0, )",
"resolved": "0.4.0",
"contentHash": "4uqaeeZOboqs8nSvYnQXnGOSTyPo4SvV4NH3o+Ls3OEV1d9VipYS09/8/DcmcklK7hWuQXhrdsQd1b6Vi0a//w==",
"requested": "[0.4.2, )",
"resolved": "0.4.2",
"contentHash": "umDR9uAzO8KPgb96O6llqN7DIv7oqATB4MPr3UrDCJ6Su+l7KJhB7lwItf/cw727e1jKTG9QEqkW6tBGjYoe4w==",
"dependencies": {
"Microsoft.CSharp": "4.7.0",
"System.Buffers": "4.5.1",
Expand Down
12 changes: 8 additions & 4 deletions src/Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@
using Elastic.Transport;
using Moq;
using Playground;
using CreateResponse = Elastic.Clients.Elasticsearch.IndexManagement.CreateResponse;
using CreateIndexResponse = Elastic.Clients.Elasticsearch.IndexManagement.CreateResponse;

// const string IndexName = "stock-demo-v1";

var mockedResponse = ResponseFactory.CreateResponse(new CreateResponse { Acknowledged = true, Index = "testing", ShardsAcknowledged = true }, 200);
var createResponse = new CreateIndexResponse { Acknowledged = true, Index = "testing", ShardsAcknowledged = true };
var mockedResponse = TestableResponseFactory.CreateSuccessfulResponse(createResponse, 201);

var mockedClient = Mock.Of<ElasticsearchClient>(e =>
e.Indices.Create<It.IsAnyType>() == mockedResponse);

var testResponse = mockedClient.Indices.Create<Person>();

if (testResponse.IsValidResponse)
Console.WriteLine("SUCCESS");

// ALTERNATIVE

var stubbedClient = new TestableElasticsearchClient();
Expand Down Expand Up @@ -291,6 +295,6 @@ public class TestableElasticsearchClient : ElasticsearchClient

public class TestIndicesNamespace : IndicesNamespacedClient
{
public override CreateResponse Create<TDocument>() =>
ResponseFactory.CreateResponse(new CreateResponse { Acknowledged = true, Index = "testing", ShardsAcknowledged = true }, 200);
public override CreateIndexResponse Create<TDocument>() =>
TestableResponseFactory.CreateSuccessfulResponse(new CreateIndexResponse { Acknowledged = true, Index = "testing", ShardsAcknowledged = true }, 201);
}
Loading