Skip to content

Commit 415ff78

Browse files
committed
Improvements to documentation
Respect the indentation in the source Allow all of <,>,&lt; and &gt; within multiline comments
1 parent 4a4d9b8 commit 415ff78

File tree

43 files changed

+560
-350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+560
-350
lines changed

docs/asciidoc/Aggregations/Bucket/Children/ChildrenAggregationMapping.doc.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var createProjectIndex = TestClient.GetClient().CreateIndex(typeof(Project), c =
99
.Mappings(map=>map
1010
.Map<Project>(m=>m.AutoMap())
1111
.Map<CommitActivity>(m=>m
12-
.Parent<Project>()
12+
.Parent<Project>()
1313
)
1414
)
1515
);

docs/asciidoc/ClientConcepts/ConnectionPooling/BuildingBlocks/ConnectionPooling.Doc.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
Connection pooling is the internal mechanism that takes care of registering what nodes there are in the cluster and which
33
we can use to issue client calls on.
44

5+
56
== SingleNodeConnectionPool
67
The simplest of all connection pools, this takes a single `Uri` and uses that to connect to elasticsearch for all the calls
78
It doesn't opt in to sniffing and pinging behavior, and will never mark nodes dead or alive. The one `Uri` it holds is always
89
ready to go.
910

11+
1012
[source, csharp]
1113
----
1214
var uri = new Uri("http://localhost:9201");
@@ -62,6 +64,7 @@ client.ConnectionSettings.ConnectionPool.Should().BeOfType<SingleNodeConnectionP
6264
The static connection pool is great if you have a known small sized cluster and do no want to enable
6365
sniffing to find out the cluster topology.
6466

67+
6568
[source, csharp]
6669
----
6770
var uris = Enumerable.Range(9200, 5).Select(p => new Uri("http://localhost:" + p));
@@ -109,6 +112,7 @@ client.ConnectionSettings.ConnectionPool.Should().BeOfType<StaticConnectionPool>
109112
A subclass of StaticConnectionPool that allows itself to be reseeded at run time.
110113
It comes with a very minor overhead of a `ReaderWriterLockSlim` to ensure thread safety.
111114

115+
112116
[source, csharp]
113117
----
114118
var uris = Enumerable.Range(9200, 5).Select(p => new Uri("http://localhost:" + p));

docs/asciidoc/ClientConcepts/ConnectionPooling/BuildingBlocks/DateTimeProviders.Doc.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Not typically something you'll have to pass to the client but all calls to `Syst
44
in the client have been abstracted by `IDateTimeProvider`. This allows us to unit test timeouts and clusterfailover
55
in run time not being bound to wall clock time.
66

7+
78
[source, csharp]
89
----
910
var dateTimeProvider = DateTimeProvider.Default;
@@ -14,10 +15,12 @@ dates are always returned in UTC
1415
----
1516
dateTimeProvider.Now().Should().BeCloseTo(DateTime.UtcNow);
1617
----
18+
1719
Another responsibility of this interface is to calculate the time a node has to be taken out of rotation
1820
based on the number of attempts to revive it. For very advanced use cases, this might be something of interest
1921
to provide a custom implementation for.
2022

23+
2124
[source, csharp]
2225
----
2326
var dateTimeProvider = DateTimeProvider.Default;

docs/asciidoc/ClientConcepts/ConnectionPooling/BuildingBlocks/KeepingTrackOfNodes.Doc.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
= Keeping track of nodes
22

33

4+
45
[source, csharp]
56
----
67
var node = new Node(new Uri("http://localhost:9200"));
@@ -26,6 +27,7 @@ node.IsResurrected.Should().BeTrue();
2627
When instantiating your connection pool you could switch these to false to initialize the client to
2728
a known cluster topology.
2829

30+
2931
passing a node with a path should be preserved. Sometimes an elasticsearch node lives behind a proxy
3032

3133
[source, csharp]
@@ -64,6 +66,7 @@ node.IsAlive.Should().BeTrue();
6466
every time a node is marked dead the number of attempts should increase
6567
and the passed datetime should be exposed.
6668

69+
6770
[source, csharp]
6871
----
6972
var deadUntil = DateTime.Now.AddMinutes(1);

docs/asciidoc/ClientConcepts/ConnectionPooling/BuildingBlocks/RequestPipelines.doc.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Every request is executed in the context of `RequestPipeline` when using the default `ITransport` implementation.
33

44

5+
56
[source, csharp]
67
----
78
var settings = TestClient.CreateSettings();
@@ -119,6 +120,7 @@ sniffingPipeline.StaleClusterState.Should().BeTrue();
119120
A request pipeline also checks whether the overall time across multiple retries exceeds the request timeout
120121
See the maxretry documentation for more details, here we assert that our request pipeline exposes this propertly
121122

123+
122124
[source, csharp]
123125
----
124126
var dateTime = new TestableDateTimeProvider();

docs/asciidoc/ClientConcepts/ConnectionPooling/BuildingBlocks/Transports.Doc.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
= Transports
2+
23
The `ITransport` interface can be seen as the motor block of the client. It's interface is deceitfully simple.
34
It's ultimately responsible from translating a client call to a response. If for some reason you do not agree with the way we wrote
45
the internals of the client, by implementing a custom `ITransport`, you can circumvent all of it and introduce your own.
56

67

8+
79
Transport is generically typed to a type that implements IConnectionConfigurationValues
810
This is the minimum ITransport needs to report back for the client to function.
911
e.g in the low level client, transport is instantiated like this:

docs/asciidoc/ClientConcepts/ConnectionPooling/Exceptions/UnexpectedExceptions.doc.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ out the client as an UnexpectedElasticsearchClientException, regardless whether
44
An IConnection is in charge of knowning what exceptions it can recover from or not. The default IConnection that is based on WebRequest can and
55
will recover from WebExceptions but others will be grounds for immediately exiting the pipeline.
66

7+
78
[source, csharp]
89
----
910
var audit = new Auditor(() => Framework.Cluster
@@ -33,12 +34,14 @@ e.FailureReason.Should().Be(PipelineFailure.Unexpected);
3334
e.InnerException.Should().NotBeNull();
3435
e.InnerException.Message.Should().Be("boom!");
3536
----
37+
3638
Sometimes an unexpected exception happens further down in the pipeline, this is why we
3739
wrap them inside an UnexpectedElasticsearchClientException so that information about where
3840
in the pipeline the unexpected exception is not lost, here a call to 9200 fails using a webexception.
3941
It then falls over to 9201 which throws an hard exception from within IConnection. We assert that we
4042
can still see the audit trail for the whole coordinated request.
4143

44+
4245
[source, csharp]
4346
----
4447
var audit = new Auditor(() => Framework.Cluster
@@ -68,10 +71,12 @@ e.FailureReason.Should().Be(PipelineFailure.Unexpected);
6871
e.InnerException.Should().NotBeNull();
6972
e.InnerException.Message.Should().Be("boom!");
7073
----
74+
7175
An unexpected hard exception on ping and sniff is something we *do* try to revover from and failover.
7276
Here pinging nodes on first use is enabled and 9200 throws on ping, we still fallover to 9201's ping succeeds.
7377
However the client call on 9201 throws a hard exception we can not recover from
7478

79+
7580
[source, csharp]
7681
----
7782
var audit = new Auditor(() => Framework.Cluster

docs/asciidoc/ClientConcepts/ConnectionPooling/Exceptions/UnrecoverableExceptions.doc.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ By default the client won't throw on any ElasticsearchClientException but return
44
You can configure the client to throw using ThrowExceptions() on ConnectionSettings. The following test
55
both a client that throws and one that returns an invalid response with an `.OriginalException` exposed
66

7+
78
[source, csharp]
89
----
910
var recoverablExceptions = new[]

docs/asciidoc/ClientConcepts/ConnectionPooling/Failover/FallingOver.doc.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
When using connection pooling and the pool has sufficient nodes a request will be retried if
33
the call to a node throws an exception or returns a 502 or 503
44

5+
56
[source, csharp]
67
----
78
var audit = new Auditor(() => Framework.Cluster
@@ -21,6 +22,7 @@ audit = await audit.TraceCall(
2122
502 Bad Gateway
2223
Will be treated as an error that requires retrying
2324

25+
2426
[source, csharp]
2527
----
2628
var audit = new Auditor(() => Framework.Cluster
@@ -40,6 +42,7 @@ audit = await audit.TraceCall(
4042
503 Service Unavailable
4143
Will be treated as an error that requires retrying
4244

45+
4346
[source, csharp]
4447
----
4548
var audit = new Auditor(() => Framework.Cluster
@@ -56,8 +59,10 @@ audit = await audit.TraceCall(
5659
}
5760
);
5861
----
62+
5963
If a call returns a valid http status code other then 502/503 the request won't be retried.
6064

65+
6166
[source, csharp]
6267
----
6368
var audit = new Auditor(() => Framework.Cluster

docs/asciidoc/ClientConcepts/ConnectionPooling/MaxRetries/RespectsMaxRetry.doc.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ By default retry as many times as we have nodes. However retries still respect t
33
Meaning if you have a 100 node cluster and a request timeout of 20 seconds we will retry as many times as we can
44
but give up after 20 seconds
55

6+
67
[source, csharp]
78
----
89
var audit = new Auditor(() => Framework.Cluster
@@ -27,9 +28,11 @@ audit = await audit.TraceCall(
2728
}
2829
);
2930
----
31+
3032
When you have a 100 node cluster you might want to ensure a fixed number of retries.
3133
Remember that the actual number of requests is initial attempt + set number of retries
3234

35+
3336
[source, csharp]
3437
----
3538
var audit = new Auditor(() => Framework.Cluster
@@ -54,6 +57,7 @@ In our previous test we simulated very fast failures, in the real world a call m
5457
Here we simulate a particular heavy search that takes 10 seconds to fail, our Request timeout is set to 20 seconds.
5558
In this case it does not make sense to retry our 10 second query on 10 nodes. We should try it twice and give up before a third call is attempted
5659

60+
5761
[source, csharp]
5862
----
5963
var audit = new Auditor(() => Framework.Cluster
@@ -77,6 +81,7 @@ Here we simulate calls taking 3 seconds, a request time out of 2 and an overall
7781
We should see 5 attempts to perform this query, testing that our request timeout cuts the query off short and that our max retry timeout of 10
7882
wins over the configured request timeout
7983

84+
8085
[source, csharp]
8186
----
8287
var audit = new Auditor(() => Framework.Cluster
@@ -100,6 +105,7 @@ audit = await audit.TraceCall(
100105

101106
If your retry policy expands beyond available nodes we won't retry the same node twice
102107

108+
103109
[source, csharp]
104110
----
105111
var audit = new Auditor(() => Framework.Cluster
@@ -122,6 +128,7 @@ This makes setting any retry setting on a single node connection pool a NOOP, th
122128
Connection pooling and connection failover is about trying to fail sanely whilst still utilizing available resources and
123129
not giving up on the fail fast principle. It's *NOT* a mechanism for forcing requests to succeed.
124130

131+
125132
[source, csharp]
126133
----
127134
var audit = new Auditor(() => Framework.Cluster

0 commit comments

Comments
 (0)