Skip to content

Commit 30eabb5

Browse files
committed
Update Elastic.Transport
1 parent 824a6b8 commit 30eabb5

15 files changed

+169
-250
lines changed

Diff for: src/Elastic.Clients.Elasticsearch.Serverless/Core/ElasticsearchClientProductRegistration.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public ElasticsearchClientProductRegistration(Type markerType) : base(markerType
2525

2626
public override string ServiceIdentifier => "esv";
2727

28-
public override string DefaultMimeType => null; // Prevent base 'ElasticsearchProductRegistration' from sending the compatibility header
28+
public override string? DefaultContentType => null; // Prevent base 'ElasticsearchProductRegistration' from sending the compatibility header
2929

3030
public override MetaHeaderProvider MetaHeaderProvider => _metaHeaderProvider;
3131

3232
/// <summary>
3333
/// Elastic.Clients.Elasticsearch handles 404 in its <see cref="ElasticsearchResponse.IsValidResponse" />, we do not want the low level client throwing
3434
/// exceptions
35-
/// when <see cref="ITransportConfiguration.ThrowExceptions" /> is enabled for 404's. The client is in charge of
35+
/// when <see cref="IRequestConfiguration.ThrowExceptions" /> is enabled for 404's. The client is in charge of
3636
/// composing paths
3737
/// so a 404 never signals a wrong URL but a missing entity.
3838
/// </summary>
@@ -77,7 +77,7 @@ public class ApiVersionMetaHeaderProducer : MetaHeaderProducer
7777

7878
public override string HeaderName => "Elastic-Api-Version";
7979

80-
public override string ProduceHeaderValue(RequestData requestData) => _apiVersion;
80+
public override string ProduceHeaderValue(RequestData requestData, bool isAsync) => _apiVersion;
8181

8282
public ApiVersionMetaHeaderProducer(VersionInfo version)
8383
{

Diff for: src/Elastic.Clients.Elasticsearch.Serverless/Elastic.Clients.Elasticsearch.Serverless.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<Nullable>annotations</Nullable>
2222
</PropertyGroup>
2323
<ItemGroup>
24-
<PackageReference Include="Elastic.Transport" Version="0.4.26" />
24+
<PackageReference Include="Elastic.Transport" Version="0.5.2" />
2525
</ItemGroup>
2626
<ItemGroup>
2727
<InternalsVisibleTo Include="Tests" Key="$(ExposedPublicKey)" />

Diff for: src/Elastic.Clients.Elasticsearch/Core/ElasticsearchClientProductRegistration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public ElasticsearchClientProductRegistration(Type markerType) : base(markerType
1818
/// <summary>
1919
/// Elastic.Clients.Elasticsearch handles 404 in its <see cref="ElasticsearchResponse.IsValidResponse" />, we do not want the low level client throwing
2020
/// exceptions
21-
/// when <see cref="ITransportConfiguration.ThrowExceptions" /> is enabled for 404's. The client is in charge of
21+
/// when <see cref="IRequestConfiguration.ThrowExceptions" /> is enabled for 404's. The client is in charge of
2222
/// composing paths
2323
/// so a 404 never signals a wrong URL but a missing entity.
2424
/// </summary>

Diff for: src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<Nullable>annotations</Nullable>
2222
</PropertyGroup>
2323
<ItemGroup>
24-
<PackageReference Include="Elastic.Transport" Version="0.4.26" />
24+
<PackageReference Include="Elastic.Transport" Version="0.5.2" />
2525
</ItemGroup>
2626
<ItemGroup>
2727
<InternalsVisibleTo Include="Tests" Key="$(ExposedPublicKey)" />

Diff for: src/Elastic.Clients.Elasticsearch/_Shared/Api/BulkRequest.cs

+14-6
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ namespace Elastic.Clients.Elasticsearch;
3232

3333
public partial class BulkRequest : IStreamSerializable
3434
{
35-
internal Request Self => this;
35+
private static readonly IRequestConfiguration RequestConfigSingleton = new RequestConfiguration
36+
{
37+
Accept = "application/json",
38+
ContentType = "application/x-ndjson"
39+
};
3640

37-
public BulkOperationsCollection Operations { get; set; }
41+
internal Request Self => this;
3842

39-
internal override string ContentType => "application/x-ndjson";
43+
protected internal override IRequestConfiguration RequestConfig => RequestConfigSingleton;
4044

41-
internal override string Accept => "application/json";
45+
public BulkOperationsCollection Operations { get; set; }
4246

4347
public void Serialize(Stream stream, IElasticsearchClientSettings settings, SerializationFormatting formatting = SerializationFormatting.None)
4448
{
@@ -87,9 +91,13 @@ public async Task SerializeAsync(Stream stream, IElasticsearchClientSettings set
8791

8892
public sealed partial class BulkRequestDescriptor : IStreamSerializable
8993
{
90-
internal override string ContentType => "application/x-ndjson";
94+
private static readonly IRequestConfiguration RequestConfigSingleton = new RequestConfiguration
95+
{
96+
Accept = "application/json",
97+
ContentType = "application/x-ndjson"
98+
};
9199

92-
internal override string Accept => "application/json";
100+
protected internal override IRequestConfiguration RequestConfig => RequestConfigSingleton;
93101

94102
private readonly BulkOperationsCollection _operations = new();
95103

Diff for: src/Elastic.Clients.Elasticsearch/_Shared/Api/Esql/EsqlQueryRequest.cs

+11-16
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@
1212
#if ELASTICSEARCH_SERVERLESS
1313
namespace Elastic.Clients.Elasticsearch.Serverless.Esql;
1414
#else
15-
1615
namespace Elastic.Clients.Elasticsearch.Esql;
1716
#endif
1817

19-
internal sealed class EsqlResponseBuilder : CustomResponseBuilder
18+
internal sealed class EsqlResponseBuilder : TypedResponseBuilder<EsqlQueryResponse>
2019
{
21-
public override object DeserializeResponse(Serializer serializer, ApiCallDetails response, Stream stream)
20+
protected override EsqlQueryResponse? Build(ApiCallDetails apiCallDetails, RequestData requestData,
21+
Stream responseStream,
22+
string contentType, long contentLength)
2223
{
23-
var bytes = stream switch
24+
var bytes = responseStream switch
2425
{
2526
MemoryStream ms => ms.ToArray(),
26-
_ => BytesFromStream(stream)
27+
_ => BytesFromStream(responseStream)
2728
};
2829

2930
return new EsqlQueryResponse { Data = bytes };
@@ -37,13 +38,14 @@ static byte[] BytesFromStream(Stream stream)
3738
}
3839
}
3940

40-
public override async Task<object> DeserializeResponseAsync(Serializer serializer, ApiCallDetails response, Stream stream,
41-
CancellationToken ctx = new CancellationToken())
41+
protected override async Task<EsqlQueryResponse?> BuildAsync(ApiCallDetails apiCallDetails, RequestData requestData,
42+
Stream responseStream,
43+
string contentType, long contentLength, CancellationToken cancellationToken = default)
4244
{
43-
var bytes = stream switch
45+
var bytes = responseStream switch
4446
{
4547
MemoryStream ms => ms.ToArray(),
46-
_ => await BytesFromStreamAsync(stream, ctx).ConfigureAwait(false)
48+
_ => await BytesFromStreamAsync(responseStream, cancellationToken).ConfigureAwait(false)
4749
};
4850

4951
return new EsqlQueryResponse { Data = bytes };
@@ -62,10 +64,3 @@ static async Task<byte[]> BytesFromStreamAsync(Stream stream, CancellationToken
6264
}
6365
}
6466
}
65-
66-
public sealed partial class EsqlQueryRequestParameters
67-
{
68-
private static readonly EsqlResponseBuilder ResponseBuilder = new();
69-
70-
public EsqlQueryRequestParameters() => CustomResponseBuilder = ResponseBuilder;
71-
}

0 commit comments

Comments
 (0)