(
private uri: string,
private context: Record<string, any>
)
| 115 | compressor: CompressorName | null; |
| 116 | |
| 117 | constructor( |
| 118 | private uri: string, |
| 119 | private context: Record<string, any> |
| 120 | ) { |
| 121 | const url = new ConnectionString(uri); |
| 122 | const { hosts } = url; |
| 123 | const hostAddresses = hosts.map(HostAddress.fromString); |
| 124 | this.version = context.version; |
| 125 | this.clientSideEncryption = context.clientSideEncryption; |
| 126 | this.cryptSharedVersion = context.cryptShared; |
| 127 | this.parameters = { ...context.parameters }; |
| 128 | this.singleMongosLoadBalancerUri = context.singleMongosLoadBalancerUri; |
| 129 | this.multiMongosLoadBalancerUri = context.multiMongosLoadBalancerUri; |
| 130 | this.topologyType = this.isLoadBalanced ? TopologyType.LoadBalanced : context.topologyType; |
| 131 | this.buildInfo = context.buildInfo; |
| 132 | this.serverApi = context.serverApi; |
| 133 | this.isSrv = uri.indexOf('mongodb+srv') > -1; |
| 134 | this.compressor = getCompressor(process.env.COMPRESSOR); |
| 135 | this.options = { |
| 136 | hosts, |
| 137 | hostAddresses, |
| 138 | hostAddress: hostAddresses[0], |
| 139 | host: hostAddresses[0].host, |
| 140 | port: typeof hostAddresses[0].host === 'string' && hostAddresses[0].port, |
| 141 | db: url.pathname.slice(1) ? url.pathname.slice(1) : 'integration_tests', |
| 142 | replicaSet: url.searchParams.get('replicaSet'), |
| 143 | proxyURIParams: url.searchParams.get('proxyHost') |
| 144 | ? { |
| 145 | proxyHost: url.searchParams.get('proxyHost'), |
| 146 | proxyPort: Number(url.searchParams.get('proxyPort')), |
| 147 | proxyUsername: url.searchParams.get('proxyUsername'), |
| 148 | proxyPassword: url.searchParams.get('proxyPassword') |
| 149 | } |
| 150 | : undefined |
| 151 | }; |
| 152 | if (url.username) { |
| 153 | this.options.auth = { |
| 154 | username: url.username, |
| 155 | password: url.password |
| 156 | }; |
| 157 | } |
| 158 | |
| 159 | this.filters = Object.fromEntries( |
| 160 | context.filters.map(filter => [filter.constructor.name, filter]) |
| 161 | ); |
| 162 | } |
| 163 | |
| 164 | get isLoadBalanced() { |
| 165 | return !!this.singleMongosLoadBalancerUri && !!this.multiMongosLoadBalancerUri; |
nothing calls this directly
no test coverage detected