Skip to content

Drop broken support for roles #2673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions docs/reference/basic-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const client = new Client({

| | |
| --- | --- |
| `node` or `nodes` | The Elasticsearch endpoint to use.<br> It can be a single string or an array of strings:<br><br>```js<br>node: 'http://localhost:9200'<br>```<br><br>Or it can be an object (or an array of objects) that represents the node:<br><br>```js<br>node: {<br> url: new URL('http://localhost:9200'),<br> tls: 'tls options',<br> agent: 'http agent options',<br> id: 'custom node id',<br> headers: { 'custom': 'headers' }<br> roles: {<br> master: true,<br> data: true,<br> ingest: true,<br> ml: false<br> }<br>}<br>```<br> |
| `auth` | Your authentication data. You can use both basic authentication and [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).<br> See [Authentication](/reference/connecting.md#authentication) for more details.<br> *Default:* `null`<br><br>Basic authentication:<br><br>```js<br>auth: {<br> username: 'elastic',<br> password: 'changeme'<br>}<br>```<br><br>[ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key) authentication:<br><br>```js<br>auth: {<br> apiKey: 'base64EncodedKey'<br>}<br>```<br><br>Bearer authentication, useful for [service account tokens](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token). Be aware that it does not handle automatic token refresh:<br><br>```js<br>auth: {<br> bearer: 'token'<br>}<br>```<br> |
| `node` or `nodes` | The Elasticsearch endpoint to use.<br> It can be a single string or an array of strings:<br><br><pre><code class="language-js hljs language-javascript"><br>node: 'http://localhost:9200'<br></code></pre><br><br>Or it can be an object (or an array of objects) that represents the node:<br><br><pre><code class="language-js hljs language-javascript"><br>node: {<br> url: new URL('http://localhost:9200'),<br> tls: 'tls options',<br> agent: 'http agent options',<br> id: 'custom node id',<br> headers: { 'custom': 'headers' }<br> roles: {<br> master: true,<br> data: true,<br> ingest: true,<br> ml: false<br> }<br>}<br></code></pre><br> |
| `auth` | Your authentication data. You can use both basic authentication and [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).<br> See [Authentication](/reference/connecting.md#authentication) for more details.<br> *Default:* `null`<br><br>Basic authentication:<br><br><pre><code class="language-js hljs language-javascript"><br>auth: {<br> username: 'elastic',<br> password: 'changeme'<br>}<br></code></pre><br><br>[ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key) authentication:<br><br><pre><code class="language-js hljs language-javascript"><br>auth: {<br> apiKey: 'base64EncodedKey'<br>}<br></code></pre><br><br>Bearer authentication, useful for [service account tokens](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token). Be aware that it does not handle automatic token refresh:<br><br><pre><code class="language-js hljs language-javascript"><br>auth: {<br> bearer: 'token'<br>}<br></code></pre><br> |
| `maxRetries` | `number` - Max number of retries for each request.<br>*Default:* `3` |
| `requestTimeout` | `number` - Max request timeout in milliseconds for each request.<br>*Default:* No value |
| `pingTimeout` | `number` - Max ping request timeout in milliseconds for each request.<br>*Default:* `3000` |
Expand All @@ -33,19 +33,18 @@ const client = new Client({
| `suggestCompression` | `boolean` - Adds `accept-encoding` header to every request.<br>*Default:* `false` |
| `compression` | `string, boolean` - Enables gzip request body compression.<br>*Options:* `'gzip'`, `false`<br>*Default:* `false` |
| `tls` | `http.SecureContextOptions` - tls [configuraton](https://nodejs.org/api/tls.md).<br>*Default:* `null` |
| `proxy` | `string, URL` - If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.<br> *Default:* `null`<br><br>```js<br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://localhost:8080'<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://user:pwd@localhost:8080'<br>})<br>```<br> |
| `agent` | `http.AgentOptions, function` - http agent [options](https://nodejs.org/api/http.md#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.<br> *Default:* `null`<br><br>```js<br>const client = new Client({<br> node: 'http://localhost:9200',<br> agent: { agent: 'options' }<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // the function takes as parameter the option<br> // object passed to the Connection constructor<br> agent: (opts) => new CustomAgent()<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // Disable agent and keep-alive<br> agent: false<br>})<br>```<br> |
| `nodeFilter` | `function` - Filters which node not to use for a request.<br> *Default:*<br><br>```js<br>function defaultNodeFilter (node) {<br> // avoid master only nodes<br> if (node.roles.master === true &&<br> node.roles.data === false &&<br> node.roles.ingest === false) {<br> return false<br> }<br> return true<br>}<br>```<br> |
| `nodeSelector` | `function` - custom selection strategy.<br> *Options:* `'round-robin'`, `'random'`, custom function<br> *Default:* `'round-robin'`<br> *Custom function example:*<br><br>```js<br>function nodeSelector (connections) {<br> const index = calculateIndex()<br> return connections[index]<br>}<br>```<br> |
| `generateRequestId` | `function` - function to generate the request id for every request, it takes two parameters, the request parameters and options.<br> By default it generates an incremental integer for every request.<br> *Custom function example:*<br><br>```js<br>function generateRequestId (params, options) {<br> // your id generation logic<br> // must be syncronous<br> return 'id'<br>}<br>```<br> |
| `proxy` | `string, URL` - If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.<br> *Default:* `null`<br><br><pre><code class="language-js hljs language-javascript"><br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://localhost:8080'<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://user:pwd@localhost:8080'<br>})<br></code></pre><br> |
| `agent` | `http.AgentOptions, function` - http agent [options](https://nodejs.org/api/http.md#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.<br> *Default:* `null`<br><br><pre><code class="language-js hljs language-javascript"><br>const client = new Client({<br> node: 'http://localhost:9200',<br> agent: { agent: 'options' }<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // the function takes as parameter the option<br> // object passed to the Connection constructor<br> agent: (opts) => new CustomAgent()<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // Disable agent and keep-alive<br> agent: false<br>})<br></code></pre><br> |
| `nodeFilter` | `function` - Takes a `Connection` and returns `true` if it can be sent a request, otherwise `false`.<br> *Default:*<br><br><pre><code class="language-js hljs language-javascript"><br>() => true<br></code></pre><br> |
| `nodeSelector` | `function` - custom selection strategy.<br> *Options:* `'round-robin'`, `'random'`, custom function<br> *Default:* `'round-robin'`<br> *Custom function example:*<br><br><pre><code class="language-js hljs language-javascript"><br>function nodeSelector (connections) {<br> const index = calculateIndex()<br> return connections[index]<br>}<br></code></pre><br> |
| `generateRequestId` | `function` - function to generate the request id for every request, it takes two parameters, the request parameters and options.<br> By default it generates an incremental integer for every request.<br> *Custom function example:*<br><br><pre><code class="language-js hljs language-javascript"><br>function generateRequestId (params, options) {<br> // your id generation logic<br> // must be syncronous<br> return 'id'<br>}<br></code></pre><br> |
| `name` | `string, symbol` - The name to identify the client instance in the events.<br>*Default:* `elasticsearch-js` |
| `opaqueIdPrefix` | `string` - A string that will be use to prefix any `X-Opaque-Id` header.<br>See [`X-Opaque-Id` support](/reference/observability.md#_x_opaque_id_support) for more details.<br>_Default:* `null` |
| `headers` | `object` - A set of custom headers to send in every request.<br>*Default:* `{}` |
| `context` | `object` - A custom object that you can use for observability in your events.It will be merged with the API level context option.<br>*Default:* `null` |
| `enableMetaHeader` | `boolean` - If true, adds an header named `'x-elastic-client-meta'`, containing some minimal telemetry data,such as the client and platform version.<br>*Default:* `true` |
| `cloud` | `object` - Custom configuration for connecting to [Elastic Cloud](https://cloud.elastic.co). See [Authentication](/reference/connecting.md) for more details.<br> *Default:* `null`<br> *Cloud configuration example:*<br><br>```js<br>const client = new Client({<br> cloud: {<br> id: '<cloud-id>'<br> },<br> auth: {<br> username: 'elastic',<br> password: 'changeme'<br> }<br>})<br>```<br> |
| `cloud` | `object` - Custom configuration for connecting to [Elastic Cloud](https://cloud.elastic.co). See [Authentication](/reference/connecting.md) for more details.<br> *Default:* `null`<br> *Cloud configuration example:*<br><br><pre><code class="language-js hljs language-javascript"><br>const client = new Client({<br> cloud: {<br> id: '<cloud-id>'<br> },<br> auth: {<br> username: 'elastic',<br> password: 'changeme'<br> }<br>})<br></code></pre><br> |
| `disablePrototypePoisoningProtection` | `boolean`, `'proto'`, `'constructor'` - The client can protect you against prototype poisoning attacks. Read [this article](https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08) to learn more about this security concern. If needed, you can enable prototype poisoning protection entirely (`false`) or one of the two checks (`'proto'` or `'constructor'`). For performance reasons, it is disabled by default. Read the `secure-json-parse` [documentation](https://github.com/fastify/secure-json-parse) to learn more.<br>*Default:* `true` |
| `caFingerprint` | `string` - If configured, verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint. Only accepts SHA256 digest fingerprints.<br>*Default:* `null` |
| `maxResponseSize` | `number` - When configured, it verifies that the uncompressed response size is lower than the configured number, if it’s higher it will abort the request. It cannot be higher than buffer.constants.MAX_STRING_LENGTH<br>*Default:* `null` |
| `maxCompressedResponseSize` | `number` - When configured, it verifies that the compressed response size is lower than the configured number, if it’s higher it will abort the request. It cannot be higher than buffer.constants.MAX_LENGTH<br>*Default:* `null` |

7 changes: 0 additions & 7 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ export interface NodeOptions {
ssl?: TlsConnectionOptions
/** @property headers Custom HTTP headers that should be sent with each request */
headers?: Record<string, any>
/** @property roles Common Elasticsearch roles that can be assigned to this node. Can be helpful when writing custom nodeFilter or nodeSelector functions. */
roles?: {
master: boolean
data: boolean
ingest: boolean
ml: boolean
}
}

export interface ClientOptions {
Expand Down
Loading