common.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ServerType = exports.TopologyType = exports.STATE_CONNECTED = exports.STATE_CONNECTING = exports.STATE_CLOSED = exports.STATE_CLOSING = void 0;
  4. exports._advanceClusterTime = _advanceClusterTime;
  5. // shared state names
  6. exports.STATE_CLOSING = 'closing';
  7. exports.STATE_CLOSED = 'closed';
  8. exports.STATE_CONNECTING = 'connecting';
  9. exports.STATE_CONNECTED = 'connected';
  10. /**
  11. * An enumeration of topology types we know about
  12. * @public
  13. */
  14. exports.TopologyType = Object.freeze({
  15. Single: 'Single',
  16. ReplicaSetNoPrimary: 'ReplicaSetNoPrimary',
  17. ReplicaSetWithPrimary: 'ReplicaSetWithPrimary',
  18. Sharded: 'Sharded',
  19. Unknown: 'Unknown',
  20. LoadBalanced: 'LoadBalanced'
  21. });
  22. /**
  23. * An enumeration of server types we know about
  24. * @public
  25. */
  26. exports.ServerType = Object.freeze({
  27. Standalone: 'Standalone',
  28. Mongos: 'Mongos',
  29. PossiblePrimary: 'PossiblePrimary',
  30. RSPrimary: 'RSPrimary',
  31. RSSecondary: 'RSSecondary',
  32. RSArbiter: 'RSArbiter',
  33. RSOther: 'RSOther',
  34. RSGhost: 'RSGhost',
  35. Unknown: 'Unknown',
  36. LoadBalancer: 'LoadBalancer'
  37. });
  38. /** Shared function to determine clusterTime for a given topology or session */
  39. function _advanceClusterTime(entity, $clusterTime) {
  40. if (entity.clusterTime == null) {
  41. entity.clusterTime = $clusterTime;
  42. }
  43. else {
  44. if ($clusterTime.clusterTime.greaterThan(entity.clusterTime.clusterTime)) {
  45. entity.clusterTime = $clusterTime;
  46. }
  47. }
  48. }
  49. //# sourceMappingURL=common.js.map