Skip to content

Commit e855b09

Browse files
committed
JSCBC-1137: Create and use CppClusterCredentials and CppDnsConfig
interfaces for connection Motivation ---------- Instead of redefining a credentials object to connect we should use what is already available from the autogen tooling. Changes ------- Create CppClusterCredentials and CppDnsConfig interfaces that are used when connecting. Change-Id: Ic77cfaecd163539158093caa4d2b119d282a89d9 Reviewed-on: https://review.couchbase.org/c/couchnode/+/187863 Reviewed-by: Brett Lawson <[email protected]> Tested-by: Jared Casey <[email protected]>
1 parent 5884066 commit e855b09

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

lib/binding.ts

+16-12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ export type CppExpiry = number
1414

1515
export type CppJsonString = string | Buffer
1616

17+
export interface CppClusterCredentials {
18+
username?: string
19+
password?: string
20+
certificate_path?: string
21+
key_path?: string
22+
allowed_sasl_mechanisms?: string[]
23+
}
24+
25+
export interface CppDnsConfig {
26+
nameserver?: string
27+
port?: number
28+
dnsSrvTimeout?: number
29+
}
30+
1731
export interface CppDocumentId {
1832
bucket: string
1933
scope: string
@@ -3160,18 +3174,8 @@ export type CppError =
31603174
export interface CppConnection extends CppConnectionAutogen {
31613175
connect(
31623176
connStr: string,
3163-
credentials: {
3164-
username?: string
3165-
password?: string
3166-
certificate_path?: string
3167-
key_path?: string
3168-
allowed_sasl_mechanisms?: string[]
3169-
},
3170-
dnsOptions: {
3171-
nameserver?: string
3172-
port?: number
3173-
dnsSrvTimeout?: number
3174-
} | null,
3177+
credentials: CppClusterCredentials,
3178+
dnsOptions: CppDnsConfig | null,
31753179
callback: (err: CppError | null) => void
31763180
): void
31773181
shutdown(callback: (err: CppError | null) => void): void

lib/cluster.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
PasswordAuthenticator,
1111
CertificateAuthenticator,
1212
} from './authenticators'
13-
import binding, { CppConnection } from './binding'
13+
import binding, { CppClusterCredentials, CppConnection } from './binding'
1414
import { errorFromCpp } from './bindingutilities'
1515
import { Bucket } from './bucket'
1616
import { BucketManager } from './bucketmanager'
@@ -614,13 +614,7 @@ export class Cluster {
614614

615615
const connStr = dsnObj.toString()
616616

617-
const authOpts = {
618-
username: undefined as string | undefined,
619-
password: undefined as string | undefined,
620-
certificate_path: undefined as string | undefined,
621-
key_path: undefined as string | undefined,
622-
allowed_sasl_mechanisms: undefined as string[] | undefined,
623-
}
617+
const authOpts: CppClusterCredentials = {}
624618

625619
// lets allow `allowed_sasl_mechanisms` to override legacy connstr option
626620
for (const saslKey of ['sasl_mech_force', 'allowed_sasl_mechanisms']) {
@@ -658,7 +652,6 @@ export class Cluster {
658652
const err = errorFromCpp(cppErr)
659653
return reject(err)
660654
}
661-
662655
resolve(null)
663656
})
664657
})

0 commit comments

Comments
 (0)