(handshakeAware?: Connection | Topology | Server)
| 330 | * @internal |
| 331 | */ |
| 332 | export function maxWireVersion(handshakeAware?: Connection | Topology | Server): number { |
| 333 | if (handshakeAware) { |
| 334 | if (handshakeAware.hello) { |
| 335 | return handshakeAware.hello.maxWireVersion; |
| 336 | } |
| 337 | |
| 338 | if (handshakeAware.serverApi?.version) { |
| 339 | // We return the max supported wire version for serverAPI. |
| 340 | return MAX_SUPPORTED_WIRE_VERSION; |
| 341 | } |
| 342 | // This is the fallback case for load balanced mode. If we are building commands the |
| 343 | // object being checked will be a connection, and we will have a hello response on |
| 344 | // it. For other cases, such as retryable writes, the object will be a server or |
| 345 | // topology, and there will be no hello response on those objects, so we return |
| 346 | // the max wire version so we support retryability. Once we have a min supported |
| 347 | // wire version of 9, then the needsRetryableWriteLabel() check can remove the |
| 348 | // usage of passing the wire version into it. |
| 349 | if (handshakeAware.loadBalanced) { |
| 350 | return MAX_SUPPORTED_WIRE_VERSION; |
| 351 | } |
| 352 | |
| 353 | if ('lastHello' in handshakeAware && typeof handshakeAware.lastHello === 'function') { |
| 354 | const lastHello = handshakeAware.lastHello(); |
| 355 | if (lastHello) { |
| 356 | return lastHello.maxWireVersion; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | if ( |
| 361 | handshakeAware.description && |
| 362 | 'maxWireVersion' in handshakeAware.description && |
| 363 | handshakeAware.description.maxWireVersion != null |
| 364 | ) { |
| 365 | return handshakeAware.description.maxWireVersion; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | return 0; |
| 370 | } |
| 371 | |
| 372 | /** @internal */ |
| 373 | export function arrayStrictEqual(arr: unknown[], arr2: unknown[]): boolean { |
no test coverage detected