Skip to content

Commit b439b6c

Browse files
authored
[DOCS] Fine-tunes the Node.js client configuration section (#998)
1 parent def4be9 commit b439b6c

File tree

1 file changed

+51
-20
lines changed

1 file changed

+51
-20
lines changed

docs/configuration.asciidoc

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[[client-configuration]]
22
== Client configuration
33

4-
The client is designed to be easily configured as you see fit for your needs, following you can see all the possible basic options that you can use to configure it.
4+
The client is designed to be easily configured for your needs. In the following
5+
section, you can see the possible basic options that you can use to configure
6+
it.
57

68
[source,js]
79
----
@@ -15,7 +17,9 @@ const client = new Client({
1517
})
1618
----
1719

20+
1821
=== Basic options
22+
1923
[cols=2*]
2024
|===
2125
|`node` or `nodes`
@@ -25,7 +29,7 @@ It can be a single string or an array of strings:
2529
----
2630
node: 'http://localhost:9200'
2731
----
28-
Or it can be an object (or an array of objects) that represents the node
32+
Or it can be an object (or an array of objects) that represents the node:
2933
[source,js]
3034
----
3135
node: {
@@ -44,8 +48,10 @@ node: {
4448
----
4549

4650
|`auth`
47-
a|Your authentication data. You can use both Basic authentication and https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[ApiKey]. +
48-
See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication] for more details. +
51+
a|Your authentication data. You can use both basic authentication and
52+
{ref}/security-api-create-api-key.html[ApiKey]. +
53+
See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication]
54+
for more details. +
4955
_Default:_ `null`
5056

5157
Basic authentication:
@@ -56,7 +62,7 @@ auth: {
5662
password: 'changeme'
5763
}
5864
----
59-
https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[ApiKey] authentication:
65+
{ref}/security-api-create-api-key.html[ApiKey] authentication:
6066
[source,js]
6167
----
6268
auth: {
@@ -112,7 +118,8 @@ _Default:_ `false`
112118
_Default:_ `null`
113119

114120
|`agent`
115-
a|`http.AgentOptions, function` - http agent https://nodejs.org/api/http.html#http_new_agent_options[options], or a function that returns an actual http agent instance. +
121+
a|`http.AgentOptions, function` - http agent https://nodejs.org/api/http.html#http_new_agent_options[options],
122+
or a function that returns an actual http agent instance. +
116123
_Default:_ `null`
117124
[source,js]
118125
----
@@ -157,7 +164,8 @@ function nodeSelector (connections) {
157164
----
158165

159166
|`generateRequestId`
160-
a|`function` - function to generate the request id for every request, it takes two parameters, the request parameters and options. +
167+
a|`function` - function to generate the request id for every request, it takes
168+
two parameters, the request parameters and options. +
161169
By default it generates an incremental integer for every request. +
162170
_Custom function example:_
163171
[source,js]
@@ -178,7 +186,9 @@ _Default:_ `elasticsearch-js`
178186
_Default:_ `{}`
179187

180188
|`cloud`
181-
a|`object` - Custom configuration for connecting to https://cloud.elastic.co[Elastic Cloud]. See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication] for more details. +
189+
a|`object` - Custom configuration for connecting to
190+
https://cloud.elastic.co[Elastic Cloud]. See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication]
191+
for more details. +
182192
_Default:_ `null` +
183193
_Cloud configuration example:_
184194
[source,js]
@@ -196,17 +206,23 @@ const client = new Client({
196206

197207
|===
198208

209+
199210
=== Advanced configuration
200-
If you need to customize the client behavior heavily, you are in the right place! +
201-
The client allows you to customize the following internals:
211+
212+
If you need to customize the client behavior heavily, you are in the right
213+
place! The client allows you to customize the following internals:
202214

203215
* `Transport` class
204216
* `ConnectionPool` class
205217
* `Connection` class
206218
* `Serializer` class
207219

220+
208221
=== `Transport`
209-
This class is responsible to perform the request to Elasticsearch and handling errors, it also handle the sniffing.
222+
223+
This class is responsible for performing the request to {es} and handling
224+
errors, it also handles the sniffing.
225+
210226
[source,js]
211227
----
212228
const { Client, Transport } = require('@elastic/elasticsearch')
@@ -222,7 +238,9 @@ const client = new Client({
222238
})
223239
----
224240

225-
Sometimes you just need to inject a little snippet of your code and then continue to use the usual client code, in such case, you should call `super.method`.
241+
Sometimes you need to inject a small snippet of your code and then continue to
242+
use the usual client code. In such cases, call `super.method`:
243+
226244
[source,js]
227245
----
228246
class MyTransport extends Transport {
@@ -233,9 +251,13 @@ class MyTransport extends Transport {
233251
}
234252
----
235253

254+
236255
=== `ConnectionPool`
237-
This class is responsible for keeping in memory all the Elasticsearch Connection that we are using, there is a single Connection for every node. +
238-
Moreover, the connection pool will handle the resurrection strategies and the updates of the pool.
256+
257+
This class is responsible for keeping in memory all the {es} Connection that we
258+
are using. There is a single Connection for every node. The connection pool
259+
handles the resurrection strategies and the updates of the pool.
260+
239261
[source,js]
240262
----
241263
const { Client, ConnectionPool } = require('@elastic/elasticsearch')
@@ -252,8 +274,14 @@ const client = new Client({
252274
})
253275
----
254276

277+
255278
=== `Connection`
256-
This class represents a single Node, it holds every information we have on the node, such as roles, id, URL, custom headers and so on. The actual HTTP request is performed here, this means that if you want to swap the default HTTP client (Node.js core), you should override this class `request` method.
279+
280+
This class represents a single node, it holds every information we have on the
281+
node, such as roles, id, URL, custom headers and so on. The actual HTTP request
282+
is performed here, this means that if you want to swap the default HTTP client
283+
(Node.js core), you should override the `request` method of this class.
284+
257285
[source,js]
258286
----
259287
const { Client, Connection } = require('@elastic/elasticsearch')
@@ -269,13 +297,16 @@ const client = new Client({
269297
})
270298
----
271299

300+
272301
=== `Serializer`
273-
This class is responsible of the serialization of every request, it offers the following methods:
274302

275-
* `serialize(object: any): string;`, serializes request objects
276-
* `deserialize(json: string): any;`, deserializes response strings
277-
* `ndserialize(array: any[]): string;`, serializes bulk request objects
278-
* `qserialize(object: any): string;`, serializes request query parameters
303+
This class is responsible for the serialization of every request, it offers the
304+
following methods:
305+
306+
* `serialize(object: any): string;` serializes request objects.
307+
* `deserialize(json: string): any;` deserializes response strings.
308+
* `ndserialize(array: any[]): string;` serializes bulk request objects.
309+
* `qserialize(object: any): string;` serializes request query parameters.
279310

280311
[source,js]
281312
----

0 commit comments

Comments
 (0)