mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
[@type/elasticsearch] Change string type to any in connectionClass (#25246)
* Change `connectionClass` type to any `connectionClass` can not be `string` type. I use my custom `HttpConnector` for sending custom request. * add describe `HttpConnector` class and write test * import `HttpConnector` and use it in `connectionClass` config
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
import * as elasticsearch from "elasticsearch";
|
||||
import HttpConnector = require("elasticsearch/src/lib/connectors/http");
|
||||
|
||||
class MyHttpConnector extends HttpConnector {
|
||||
constructor(host: any, config: any) {
|
||||
super(host, config);
|
||||
}
|
||||
}
|
||||
|
||||
let client = new elasticsearch.Client({
|
||||
host: 'localhost:9200',
|
||||
log: 'trace'
|
||||
});
|
||||
|
||||
client = new elasticsearch.Client({
|
||||
host: 'localhost:9200',
|
||||
connectionClass: MyHttpConnector
|
||||
});
|
||||
|
||||
client = new elasticsearch.Client({
|
||||
hosts: [
|
||||
'box1.server.org',
|
||||
|
||||
Vendored
+3
-1
@@ -12,6 +12,8 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import HttpConnector = require("./src/lib/connectors/http");
|
||||
|
||||
export class Client {
|
||||
constructor(params: ConfigOptions);
|
||||
cat: Cat;
|
||||
@@ -111,7 +113,7 @@ export interface ConfigOptions {
|
||||
keepAlive?: boolean;
|
||||
maxSockets?: number;
|
||||
suggestCompression?: boolean;
|
||||
connectionClass?: string;
|
||||
connectionClass?: string | typeof HttpConnector;
|
||||
sniffedNodesProtocol?: string;
|
||||
ssl?: object;
|
||||
selector?: any;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// HttpConnector for elasticsearch
|
||||
|
||||
export = HttpConnector;
|
||||
|
||||
declare class HttpConnector {
|
||||
constructor(host: any, config: any);
|
||||
|
||||
// onStatusSet(handler: (status: any) => void): void;
|
||||
createAgent(config: any): any;
|
||||
makeAgentConfig(config: any): any;
|
||||
makeReqParams(params: any): any;
|
||||
request(params: any, callback: (error: any, response: any, status: any, headers: any) => void): void;
|
||||
}
|
||||
Reference in New Issue
Block a user