Skip to content

Commit

Permalink
Phase 2 Refactoring (#52)
Browse files Browse the repository at this point in the history
* Response and ApiCallDetails refactoring

* Refactoring to abstract types

* Remove IRequestParameters

* Remove ITransport

* Remove IProduceRegistration

* Remove IRequestPipeline

* Reformatting to file scoped namespaces

* VirtualizedCluster refactoring

* Fix BOM
  • Loading branch information
stevejgordon authored Nov 9, 2022
1 parent d6e42bf commit 38d8f54
Show file tree
Hide file tree
Showing 188 changed files with 12,709 additions and 12,914 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ csharp_space_between_method_call_parameter_list_parentheses = false:error
csharp_preserve_single_line_statements = false:error
csharp_preserve_single_line_blocks = true:error

csharp_style_namespace_declarations = file_scoped

# Resharper
resharper_csharp_braces_for_lock=required_for_complex
resharper_csharp_braces_for_using=required_for_complex
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var response = transport.Get<StringResponse>("/");
var headResponse = transport.Head("/");
```

`Get` and `Head` are extension methods to the only method `ITransport` dictates namely `Request()` and its async variant.
`Get` and `Head` are extension methods to the only method `HttpTransport` dictates namely `Request()` and its async variant.

Wrapping clients most likely will list out all `components` explicitly and use `Transport<TConfiguration>`

Expand All @@ -52,9 +52,9 @@ This allows implementers to extend `TransportConfiguration` with product/service

### Components

`ITransport` itself only defines `Request()` and `RequestAsync()` and all wrapping clients accept an `ITransport`.
`HttpTransport` itself only defines `Request()` and `RequestAsync()` and all wrapping clients accept an `HttpTransport`.

The `ITransport` implementation that this library ships models a request pipeline that can deal with a large variety of topologies
The `HttpTransport` implementation that this library ships models a request pipeline that can deal with a large variety of topologies

![request-pipeline.png](request-pipeline.png)

Expand Down Expand Up @@ -96,7 +96,7 @@ the `IConnectionPool` to the transport configuration
ONLY if a connection pool indicates it supports receiving new nodes will the transport sniff.
* `IConnection`
Abstraction for the actual IO the transport needs to perform.
* `ITransportSerializer`
* `HttpTransportSerializer`
Allows you to inject your own serializer, the default uses `System.Text.Json`
* `IProductRegistration`
Product specific implementations and metadata provider
Expand All @@ -106,24 +106,24 @@ Product specific implementations and metadata provider

* `ITransportConfigurationValues`
A transport configuration instance, explictly designed for clients to introduce subclasses of
* `IRequestPipelineFactory`
A factory creating `IRequestPipeline` instances
* `IDateTimeProvider`
* `RequestPipelineFactory`
A factory creating `RequestPipeline` instances
* `DateTimeProvider`
Abstraction around the static `DateTime.Now` so we can test algorithms without waiting on the clock on the wall.
* `IMemoryStreamFactory`
* `MemoryStreamFactory`
A factory creating `MemoryStream` instances.



### Observability

The default `ITransport` implementation ships with various `DiagnosticSources` to make the whole
The default `HttpTransport` implementation ships with various `DiagnosticSources` to make the whole
flow through the request pipeline auditable and debuggable.

Every response returned by `Transport` has to implement `ITransportResponse` which has one property `ApiCall` of
type `IApiCallDetails` which in turns holds all information relevant to the request and response.
Every response returned by `Transport` has to implement `TransportResponse` which has one property `ApiCall` of
type `ApiCallDetails` which in turns holds all information relevant to the request and response.

`NOTE:` it also exposes `response.ApiCall.DebugInformation` always holds a human readable string to indicate
`NOTE:` it also exposes `response.ApiCallDetails.DebugInformation` always holds a human readable string to indicate
what happened.

Further more `DiagnosticSources` exists for various purposes e.g (de)serialization times, time to first byte & various counters
Expand Down
10 changes: 6 additions & 4 deletions benchmarks/Elastic.Transport.Benchmarks/TransportBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Elastic.Transport.Benchmarks
{
public class TransportBenchmarks
{
private Transport _transport;
private DefaultHttpTransport _transport;

[GlobalSetup]
public void Setup()
Expand All @@ -19,7 +19,7 @@ public void Setup()
var pool = new SingleNodePool(new Uri("http://localhost:9200"));
var settings = new TransportConfiguration(pool, connection);

_transport = new Transport(settings);
_transport = new DefaultHttpTransport(settings);
}

[Benchmark]
Expand All @@ -28,9 +28,11 @@ public void Setup()
[Benchmark]
public async Task TransportSuccessfulAsyncRequestBenchmark() => await _transport.GetAsync<EmptyResponse>("/");

private class EmptyResponse : ITransportResponse
private class EmptyResponse : TransportResponse
{
public IApiCallDetails ApiCall { get; set; }
public EmptyResponse() : base() { }

public ApiCallDetails ApiCall { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion benchmarks/Elastic.Transport.Profiling/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private static async Task Main()
MemoryProfiler.GetSnapshot("start");

var config = new TransportConfiguration(new Uri("http://localhost:9200"), new ElasticsearchProductRegistration());
var transport = new Transport(config);
var transport = new DefaultHttpTransport(config);

_ = await transport.GetAsync<VoidResponse>("/");

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<InheritDocEnabled>true</InheritDocEnabled>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<ExposedPublicKey>002400000480000094000000060200000024000052534131000400000100010015b0fa59d868c7f3ea2ae67567b19e102465745f01b430a38a42b92fd41a0f5869bec1f2b33b589d78662af432fe6b789ef72d4738f7b1a86264d7aeb5185ed8995b2bb104e7c5c58845f1a618be829e410fa34a6bd7d714ece191ed68a66333a83ae7456ee32e9aeb54bc1d7410ae8c344367257e9001abb5e96ce1f1d97696</ExposedPublicKey>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 38d8f54

Please sign in to comment.