common.js 1.7 KB

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