added a warning about reusing config objects to the config docs and to the Client constructor
This commit is contained in:
@ -1,16 +1,19 @@
|
|||||||
[[configuration]]
|
[[configuration]]
|
||||||
== Configuration
|
== Configuration
|
||||||
|
|
||||||
The `Client` constructor accepts a single object as it's argument, and the following keys can be used to configure that client instance.
|
The `Client` constructor accepts a single object as it's argument. In the <<config-options>> section all of the available options/keys are listed.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
------
|
------
|
||||||
var elasticsearch = require('elasticsearch');
|
var elasticsearch = require('elasticsearch');
|
||||||
var client = new elasticsearch.Client({
|
var client = new elasticsearch.Client({
|
||||||
...
|
... config options ...
|
||||||
});
|
});
|
||||||
------
|
------
|
||||||
|
|
||||||
|
WARNING: Due to the complex nature of the configuration, the config object you pass in will be modified and can only be used to create one `Client` instance. Sorry for the inconvenience. Related Github issue: https://github.com/elasticsearch/elasticsearch-js/issues/33
|
||||||
|
|
||||||
|
[[config-options]]
|
||||||
=== Config options
|
=== Config options
|
||||||
[horizontal]
|
[horizontal]
|
||||||
`host or hosts`[[config-hosts]]::
|
`host or hosts`[[config-hosts]]::
|
||||||
|
|||||||
@ -32,6 +32,13 @@ var _ = require('./utils');
|
|||||||
function Client(config) {
|
function Client(config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
|
|
||||||
|
if (config.__reused) {
|
||||||
|
throw new Error('Do not reuse objects to configure the elasticsearch Client class: ' +
|
||||||
|
'https://github.com/elasticsearch/elasticsearch-js/issues/33');
|
||||||
|
} else {
|
||||||
|
config.__reused = true;
|
||||||
|
}
|
||||||
|
|
||||||
function EsApiClient() {
|
function EsApiClient() {
|
||||||
// our client will log minimally by default
|
// our client will log minimally by default
|
||||||
if (!config.hasOwnProperty('log')) {
|
if (!config.hasOwnProperty('log')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user