Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com> Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
35 lines
707 B
Plaintext
35 lines
707 B
Plaintext
[[transport]]
|
|
=== Transport
|
|
|
|
This class is responsible for performing the request to {es} and handling
|
|
errors, it also handles sniffing.
|
|
|
|
[source,js]
|
|
----
|
|
const { Client, Transport } = require('@elastic/elasticsearch')
|
|
|
|
class MyTransport extends Transport {
|
|
request (params, options, callback) {
|
|
// your code
|
|
}
|
|
}
|
|
|
|
const client = new Client({
|
|
Transport: MyTransport
|
|
})
|
|
----
|
|
|
|
Sometimes you need to inject a small snippet of your code and then continue to
|
|
use the usual client code. In such cases, call `super.method`:
|
|
|
|
[source,js]
|
|
----
|
|
class MyTransport extends Transport {
|
|
request (params, options, callback) {
|
|
// your code
|
|
return super.request(params, options, callback)
|
|
}
|
|
}
|
|
----
|
|
|