// Licensed to Elasticsearch B.V under one or more agreements. // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information import { expectType, expectAssignable } from 'tsd' import { URL } from 'url' import { BaseConnectionPool, ConnectionPool, CloudConnectionPool, Connection } from '../../' { const pool = new BaseConnectionPool({ Connection: Connection, ssl: { ca: 'stirng' }, emit: (event, ...args) => true, agent: { keepAlive: true }, auth: { username: 'username', password: 'password' } }) expectType(pool) expectType(pool.connections) expectType(pool.size) expectType(pool.markAlive(new Connection())) expectType(pool.markDead(new Connection())) expectType(pool.getConnection({ filter (node) { return true }, selector (connections) { return connections[0] }, requestId: 'id', name: 'name', now: Date.now() })) expectType(pool.addConnection({})) expectType(pool.removeConnection(new Connection())) expectType(pool.empty()) expectType(pool.update([])) expectType(pool.nodesToHost([], 'https')) expectType<{ url: URL }>(pool.urlToHost('url')) } { const pool = new ConnectionPool({ Connection: Connection, ssl: { ca: 'stirng' }, emit: (event, ...args) => true, agent: { keepAlive: true }, auth: { username: 'username', password: 'password' }, pingTimeout: 1000, resurrectStrategy: 'ping', sniffEnabled: true }) expectAssignable(pool) expectType(pool.connections) expectType(pool.size) expectType(pool.dead) expectAssignable(pool.markAlive(new Connection())) expectAssignable(pool.markDead(new Connection())) expectType(pool.getConnection({ filter (node) { return true }, selector (connections) { return connections[0] }, requestId: 'id', name: 'name', now: Date.now() })) expectType(pool.addConnection({})) expectAssignable(pool.removeConnection(new Connection())) expectAssignable(pool.empty()) expectAssignable(pool.update([])) expectType(pool.nodesToHost([], 'https')) expectType<{ url: URL }>(pool.urlToHost('url')) expectType(pool.resurrect({ now: Date.now(), requestId: 'id', name: 'name' })) } { const pool = new CloudConnectionPool({ Connection: Connection, ssl: { ca: 'stirng' }, emit: (event, ...args) => true, agent: { keepAlive: true }, auth: { username: 'username', password: 'password' } }) expectAssignable(pool) expectType(pool.cloudConnection) expectType(pool.getConnection()) }