* #### Throws if LB mode is true: * - hosts contains more than one host * - there is a replicaSet name set * - directConnection is set * - if srvMaxHosts is used when an srv connection string is passed in * * @throws MongoParseError
( hosts: HostAddress[] | string[], mongoOptions: MongoOptions, isSrv: boolean )
| 558 | * @throws MongoParseError |
| 559 | */ |
| 560 | function validateLoadBalancedOptions( |
| 561 | hosts: HostAddress[] | string[], |
| 562 | mongoOptions: MongoOptions, |
| 563 | isSrv: boolean |
| 564 | ): void { |
| 565 | if (mongoOptions.loadBalanced) { |
| 566 | if (hosts.length > 1) { |
| 567 | throw new MongoParseError(LB_SINGLE_HOST_ERROR); |
| 568 | } |
| 569 | if (mongoOptions.replicaSet) { |
| 570 | throw new MongoParseError(LB_REPLICA_SET_ERROR); |
| 571 | } |
| 572 | if (mongoOptions.directConnection) { |
| 573 | throw new MongoParseError(LB_DIRECT_CONNECTION_ERROR); |
| 574 | } |
| 575 | |
| 576 | if (isSrv && mongoOptions.srvMaxHosts > 0) { |
| 577 | throw new MongoParseError(class="st">'Cannot limit srv hosts with loadBalanced enabled'); |
| 578 | } |
| 579 | } |
| 580 | return; |
| 581 | } |
| 582 | |
| 583 | function setOption( |
| 584 | mongoOptions: any, |
no outgoing calls
no test coverage detected