/* * Ping connection. */ ping() { const client = this.client; return Promise.fromNode(cb => { client.ping(cb); }) .then(success => { if (!success) { return Promise.reject({ status: 502, message: 'Could not reach the elasticsearch instance!', }); } }); }
test('client.ping with callback', function userLandCode (t) { resetAgent(done(t, 'HEAD', '/')) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) client.ping(function (err) { t.error(err) agent.endTransaction() agent.flush() }) })
es.ping({ requestTimeout: 1000 }, err => { if (err) { console.error(err) process.exit(1) } })
client.ping({ // ping usually has a 3000ms timeout requestTimeout: Infinity, // undocumented params are appended to the query string hello: "elasticsearch!" }, function (error) { if (error) { console.trace('elasticsearch cluster is down!'); } else { console.log('All is well'); } });
}); try { await this.client.ping() if (await this.client.indices.exists({ index: ["site", "feed", "op_file"]
// Some ugly callbacks to init ES esClient.ping({ // ping usually has a 3000ms timeout requestTimeout: 1000 }, function (error) { if (error) { console.trace('elasticsearch cluster is down!'); errors.report('Elasticsearch Cluster appears down'); } else { console.log('All is well'); // Delete everything! // esClient.indices.delete({ // index: 'cats', // ignore: [404] // }).then(function (body) { // start(); // }, function (error) { // // oh no! // console.trace(error); // }); start(); } });
test('client.ping with promise', function userLandCode (t) { resetAgent(done(t, 'HEAD', '/')) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) client.ping().then(function () { agent.endTransaction() agent.flush() }, function (err) { t.error(err) }) })
/* * Ping connection. */ ping() { const client = this.client; return Promise.fromNode(cb => { client.ping(cb); }) .then(success => { if (!success) { return Promise.reject({ status: 502, message: 'Could not reach the elasticsearch instance!', }); } }); }
esClient.ping({ // ping usually has a 3000ms timeout requestTimeout: 1000 }, function (error) { if (error) { console.trace('elasticsearch cluster is down!'); } else { console.log('All is well'); } });