Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: πŸ› add URL upstream variations in BalancedPool types #1966

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/types/balanced-pool.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ expectAssignable<BalancedPool>(new BalancedPool('', { factory: () => new Dispatc
expectAssignable<BalancedPool>(new BalancedPool('', { factory: (origin, opts) => new Client(origin, opts) }))
expectAssignable<BalancedPool>(new BalancedPool('', { connections: 1 }))
expectAssignable<BalancedPool>(new BalancedPool(['http://localhost:4242', 'http://www.nodejs.org']))
expectAssignable<BalancedPool>(new BalancedPool([new URL('http://localhost:4242'),new URL('http://www.nodejs.org')], {}))

{
const pool = new BalancedPool('', {})
Expand All @@ -21,6 +22,8 @@ expectAssignable<BalancedPool>(new BalancedPool(['http://localhost:4242', 'http:
// upstreams
expectAssignable<BalancedPool>(pool.addUpstream('http://www.nodejs.org'))
expectAssignable<BalancedPool>(pool.removeUpstream('http://www.nodejs.org'))
expectAssignable<BalancedPool>(pool.addUpstream(new URL('http://www.nodejs.org')))
expectAssignable<BalancedPool>(pool.removeUpstream(new URL('http://www.nodejs.org')))
expectAssignable<string[]>(pool.upstreams)


Expand Down
6 changes: 3 additions & 3 deletions types/balanced-pool.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { URL } from 'url'
export default BalancedPool

declare class BalancedPool extends Dispatcher {
constructor(url: string | URL | string[], options?: Pool.Options);
constructor(url: string | string[] | URL | URL[], options?: Pool.Options);

addUpstream(upstream: string): BalancedPool;
removeUpstream(upstream: string): BalancedPool;
addUpstream(upstream: string | URL): BalancedPool;
removeUpstream(upstream: string | URL): BalancedPool;
upstreams: Array<string>;

/** `true` after `pool.close()` has been called. */
Expand Down