rename create client, fix client instance test
This commit is contained in:
18
src/helpers/es_client.js
Normal file
18
src/helpers/es_client.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import elasticsearch from 'elasticsearch';
|
||||
|
||||
export default function createClient(options) {
|
||||
let client;
|
||||
|
||||
// if there's a transport property, assume it's a client instance
|
||||
if (isClient(options)) {
|
||||
client = options;
|
||||
} else {
|
||||
client = new elasticsearch.Client(options);
|
||||
}
|
||||
|
||||
return client;
|
||||
};
|
||||
|
||||
export function isClient(client) {
|
||||
return !!client.transport;
|
||||
}
|
||||
Reference in New Issue
Block a user