Skip to content

Commit

Permalink
Remove IElasticsearchClient interface (#6161) (#6162)
Browse files Browse the repository at this point in the history
Remove IElasticsearchClient interface.

We have deemed that this interface is not all that useful as it may change between versions if APIs are added, which ends up breaking and implementations. It's not super useful for testing scenarios and we'll look to provide better options and documentation instead.

Co-authored-by: Steve Gordon <sgordon@hotmail.co.uk>
  • Loading branch information
github-actions[bot] and stevejgordon authored Mar 18, 2022
1 parent b9a07d2 commit 25459f7
Show file tree
Hide file tree
Showing 37 changed files with 113 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@

namespace Elastic.Clients.Elasticsearch;

public partial interface IElasticsearchClient
{
//HelpersNamespace Helpers { get; }

BulkAllObservable<T> BulkAll<T>(IEnumerable<T> documents, Action<BulkAllRequestDescriptor<T>> configure, CancellationToken cancellationToken = default);

BulkAllObservable<T> BulkAll<T>(IBulkAllRequest<T> request, CancellationToken cancellationToken = default);
}

public partial class ElasticsearchClient
{
//public HelpersNamespace Helpers { get; private set; }
Expand Down
42 changes: 0 additions & 42 deletions src/Elastic.Clients.Elasticsearch/Client/IElasticsearchClient.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class IndexManyExtensions
/// <param name="objects">List of objects to index, Id will be inferred (Id property or IdProperty attribute on type)</param>
/// <param name="index">Override the inferred indexname for T</param>
/// <param name="type">Override the inferred typename for T</param>
public static BulkResponse IndexMany<T>(this IElasticsearchClient client, IEnumerable<T> @objects, IndexName index = null)
public static BulkResponse IndexMany<T>(this ElasticsearchClient client, IEnumerable<T> @objects, IndexName index = null)
where T : class
{
var bulkRequest = CreateIndexBulkRequest(objects, index);
Expand All @@ -41,7 +41,7 @@ public static BulkResponse IndexMany<T>(this IElasticsearchClient client, IEnume
/// <param name="objects">List of objects to index, Id will be inferred (Id property or IdProperty attribute on type)</param>
/// <param name="index">Override the inferred indexname for T</param>
/// <param name="type">Override the inferred typename for T</param>
public static Task<BulkResponse> IndexManyAsync<T>(this IElasticsearchClient client, IEnumerable<T> objects, IndexName index = null,
public static Task<BulkResponse> IndexManyAsync<T>(this ElasticsearchClient client, IEnumerable<T> objects, IndexName index = null,
CancellationToken cancellationToken = default
)
where T : class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public abstract class
protected ConnectionConfigurationBase(NodePool nodePool, ITransportClient connection,
Serializer? serializer,
IProductRegistration registration = null)
: base(nodePool, connection, serializer, registration ?? new ElasticsearchProductRegistration(typeof(IElasticsearchClient))) =>
: base(nodePool, connection, serializer, registration ?? new ElasticsearchProductRegistration(typeof(ElasticsearchClient))) =>
UserAgent(ConnectionConfiguration.DefaultUserAgent);

bool ITransportClientConfigurationValues.IncludeServerStackTraceOnError => _includeServerStackTraceOnError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal sealed class ElasticsearchClientProductRegistration : ElasticsearchProd
{
public ElasticsearchClientProductRegistration(Type markerType) : base(markerType) { }

public static ElasticsearchClientProductRegistration DefaultForElasticsearchClientsElasticsearch { get; } = new(typeof(IElasticsearchClient));
public static ElasticsearchClientProductRegistration DefaultForElasticsearchClientsElasticsearch { get; } = new(typeof(ElasticsearchClient));

/// <summary>
/// Elastic.Clients.Elasticsearch handles 404 in its <see cref="ResponseBase.IsValid" />, we do not want the low level client throwing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1064,20 +1064,16 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
}
}

public partial class ElasticsearchClient
{
public SourceResponse<TDocument> Source<TDocument>(DocumentPath<TDocument> id, Action<SourceRequestDescriptor<TDocument>> configure = null)
{
var descriptor = new SourceRequestDescriptor<TDocument>(document: id.Document, index: id?.Self?.Index, id: id?.Self?.Id);
configure?.Invoke(descriptor);
return DoRequest<SourceRequestDescriptor<TDocument>, SourceResponse<TDocument>>(descriptor);
}
}
//public partial class ElasticsearchClient
//{
// public SourceResponse<TDocument> Source<TDocument>(DocumentPath<TDocument> id, Action<SourceRequestDescriptor<TDocument>> configure = null)
// {
// var descriptor = new SourceRequestDescriptor<TDocument>(document: id.Document, index: id?.Self?.Index, id: id?.Self?.Id);
// configure?.Invoke(descriptor);
// return DoRequest<SourceRequestDescriptor<TDocument>, SourceResponse<TDocument>>(descriptor);
// }
//}

public partial interface IElasticsearchClient
{
public SourceResponse<TDocument> Source<TDocument>(DocumentPath<TDocument> id, Action<SourceRequestDescriptor<TDocument>> configure = null);
}

public abstract partial class BulkResponseItemBase
{
Expand All @@ -1092,7 +1088,7 @@ public abstract partial class BulkResponseItemBase
// TODO - Should be added as a rule to the descriptor generator
//public sealed partial class SourceRequestDescriptor<TDocument>
//{
// public SourceRequestDescriptor(TDocument documentWithId, IndexName index = null, Id id = null) : this(index ?? typeof(TDocument), id ?? Id.From(documentWithId)) { }
// public SourceRequestDescriptor(TDocument documentWithId, IndexName index = null, Id id = null) : this(index ?? typeof(TDocument), id ?? Id.From(documentWithId)) => Doc
//}

public partial class SourceRequestDescriptor
Expand Down Expand Up @@ -1545,29 +1541,6 @@ public partial struct Refresh : IStringable

public class DocType { }

public partial interface IElasticsearchClient
{
DeleteResponse Delete<TDocument>(Id id, Action<DeleteRequestDescriptor<TDocument>> configureRequest);

Task<DeleteResponse> DeleteAsync<TDocument>(Id id, Action<DeleteRequestDescriptor<TDocument>> configureRequest, CancellationToken cancellationToken = default);

CreateResponse Create<TDocument>(TDocument document, Action<CreateRequestDescriptor<TDocument>> configureRequest);

Task<CreateResponse> CreateAsync<TDocument>(TDocument document, Action<CreateRequestDescriptor<TDocument>> configureRequest, CancellationToken cancellationToken = default);

IndexResponse Index<TDocument>(TDocument document, Action<IndexRequestDescriptor<TDocument>> configureRequest);

Task<IndexResponse> IndexAsync<TDocument>(TDocument document, Action<IndexRequestDescriptor<TDocument>> configureRequest, CancellationToken cancellationToken = default);

Task<UpdateResponse<TDocument>> UpdateAsync<TDocument, TPartialDocument>(IndexName index, Id id, Action<UpdateRequestDescriptor<TDocument, TPartialDocument>> configureRequest = null, CancellationToken cancellationToken = default);

UpdateResponse<TDocument> Update<TDocument, TPartialDocument>(IndexName index, Id id, Action<UpdateRequestDescriptor<TDocument, TPartialDocument>> configureRequest = null);

CountResponse Count<TDocument>(Action<CountRequestDescriptor<TDocument>> configureRequest = null);

Task<CountResponse> CountAsync<TDocument>(Action<CountRequestDescriptor<TDocument>> configureRequest = null, CancellationToken cancellationToken = default);
}

public partial class ElasticsearchClient
{
public IndexResponse Index<TDocument>(TDocument document, Action<IndexRequestDescriptor<TDocument>> configureRequest)
Expand Down Expand Up @@ -1626,11 +1599,11 @@ public UpdateResponse<TDocument> Update<TDocument, TPartialDocument>(IndexName i
return DoRequest<UpdateRequestDescriptor<TDocument, TPartialDocument>, UpdateResponse<TDocument>>(descriptor);
}

public SourceResponse<TDocument> Source<TDocument>(DocumentPath<TDocument> id, Action<SourceRequestDescriptor> configureRequest = null)
public SourceResponse<TDocument> Source<TDocument>(DocumentPath<TDocument> id, Action<SourceRequestDescriptor<TDocument>> configureRequest = null)
{
var descriptor = new SourceRequestDescriptor(typeof(TDocument), new Id(typeof(TDocument)));
var descriptor = new SourceRequestDescriptor<TDocument>(document: id.Document, index: id?.Self?.Index ?? typeof(TDocument), id: id?.Self?.Id ?? Id.From(id.Document));
configureRequest?.Invoke(descriptor);
return DoRequest<SourceRequestDescriptor, SourceResponse<TDocument>>(descriptor);
return DoRequest<SourceRequestDescriptor<TDocument>, SourceResponse<TDocument>>(descriptor);
}

public CountResponse Count<TDocument>(Action<CountRequestDescriptor<TDocument>> configureRequest = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BulkAllObservable<T> : IDisposable, IObservable<BulkAllResponse>
private readonly int _backOffRetries;
private readonly TimeSpan _backOffTime;
private readonly int _bulkSize;
private readonly IElasticsearchClient _client;
private readonly ElasticsearchClient _client;

private readonly CancellationToken _compositeCancelToken;
private readonly CancellationTokenSource _compositeCancelTokenSource;
Expand All @@ -36,7 +36,7 @@ public class BulkAllObservable<T> : IDisposable, IObservable<BulkAllResponse>

private readonly Action<BulkResponse> _bulkResponseCallback;

public BulkAllObservable(IElasticsearchClient client, IBulkAllRequest<T> partitionedBulkRequest, CancellationToken cancellationToken = default)
public BulkAllObservable(ElasticsearchClient client, IBulkAllRequest<T> partitionedBulkRequest, CancellationToken cancellationToken = default)
{
_client = client;
_partitionedBulkRequest = partitionedBulkRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#nullable restore
namespace Elastic.Clients.Elasticsearch
{
public partial class ElasticsearchClient : IElasticsearchClient
public partial class ElasticsearchClient
{
public AsyncSearchNamespace AsyncSearch { get; private set; }

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Tests.Core/Client/FixedResponseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Tests.Core.Client
{
public static class FixedResponseClient
{
public static IElasticsearchClient Create(
public static ElasticsearchClient Create(
object response,
int statusCode = 200,
Func<ElasticsearchClientSettings, ElasticsearchClientSettings> modifySettings = null,
Expand Down
Loading

0 comments on commit 25459f7

Please sign in to comment.