events.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ServerHeartbeatFailedEvent = exports.ServerHeartbeatSucceededEvent = exports.ServerHeartbeatStartedEvent = exports.TopologyClosedEvent = exports.TopologyOpeningEvent = exports.TopologyDescriptionChangedEvent = exports.ServerClosedEvent = exports.ServerOpeningEvent = exports.ServerDescriptionChangedEvent = void 0;
  4. /**
  5. * Emitted when server description changes, but does NOT include changes to the RTT.
  6. * @public
  7. * @category Event
  8. */
  9. class ServerDescriptionChangedEvent {
  10. /** @internal */
  11. constructor(topologyId, address, previousDescription, newDescription) {
  12. this.topologyId = topologyId;
  13. this.address = address;
  14. this.previousDescription = previousDescription;
  15. this.newDescription = newDescription;
  16. }
  17. }
  18. exports.ServerDescriptionChangedEvent = ServerDescriptionChangedEvent;
  19. /**
  20. * Emitted when server is initialized.
  21. * @public
  22. * @category Event
  23. */
  24. class ServerOpeningEvent {
  25. /** @internal */
  26. constructor(topologyId, address) {
  27. this.topologyId = topologyId;
  28. this.address = address;
  29. }
  30. }
  31. exports.ServerOpeningEvent = ServerOpeningEvent;
  32. /**
  33. * Emitted when server is closed.
  34. * @public
  35. * @category Event
  36. */
  37. class ServerClosedEvent {
  38. /** @internal */
  39. constructor(topologyId, address) {
  40. this.topologyId = topologyId;
  41. this.address = address;
  42. }
  43. }
  44. exports.ServerClosedEvent = ServerClosedEvent;
  45. /**
  46. * Emitted when topology description changes.
  47. * @public
  48. * @category Event
  49. */
  50. class TopologyDescriptionChangedEvent {
  51. /** @internal */
  52. constructor(topologyId, previousDescription, newDescription) {
  53. this.topologyId = topologyId;
  54. this.previousDescription = previousDescription;
  55. this.newDescription = newDescription;
  56. }
  57. }
  58. exports.TopologyDescriptionChangedEvent = TopologyDescriptionChangedEvent;
  59. /**
  60. * Emitted when topology is initialized.
  61. * @public
  62. * @category Event
  63. */
  64. class TopologyOpeningEvent {
  65. /** @internal */
  66. constructor(topologyId) {
  67. this.topologyId = topologyId;
  68. }
  69. }
  70. exports.TopologyOpeningEvent = TopologyOpeningEvent;
  71. /**
  72. * Emitted when topology is closed.
  73. * @public
  74. * @category Event
  75. */
  76. class TopologyClosedEvent {
  77. /** @internal */
  78. constructor(topologyId) {
  79. this.topologyId = topologyId;
  80. }
  81. }
  82. exports.TopologyClosedEvent = TopologyClosedEvent;
  83. /**
  84. * Emitted when the server monitor’s hello command is started - immediately before
  85. * the hello command is serialized into raw BSON and written to the socket.
  86. *
  87. * @public
  88. * @category Event
  89. */
  90. class ServerHeartbeatStartedEvent {
  91. /** @internal */
  92. constructor(connectionId, awaited) {
  93. this.connectionId = connectionId;
  94. this.awaited = awaited;
  95. }
  96. }
  97. exports.ServerHeartbeatStartedEvent = ServerHeartbeatStartedEvent;
  98. /**
  99. * Emitted when the server monitor’s hello succeeds.
  100. * @public
  101. * @category Event
  102. */
  103. class ServerHeartbeatSucceededEvent {
  104. /** @internal */
  105. constructor(connectionId, duration, reply, awaited) {
  106. this.connectionId = connectionId;
  107. this.duration = duration;
  108. this.reply = reply ?? {};
  109. this.awaited = awaited;
  110. }
  111. }
  112. exports.ServerHeartbeatSucceededEvent = ServerHeartbeatSucceededEvent;
  113. /**
  114. * Emitted when the server monitor’s hello fails, either with an “ok: 0” or a socket exception.
  115. * @public
  116. * @category Event
  117. */
  118. class ServerHeartbeatFailedEvent {
  119. /** @internal */
  120. constructor(connectionId, duration, failure, awaited) {
  121. this.connectionId = connectionId;
  122. this.duration = duration;
  123. this.failure = failure;
  124. this.awaited = awaited;
  125. }
  126. }
  127. exports.ServerHeartbeatFailedEvent = ServerHeartbeatFailedEvent;
  128. //# sourceMappingURL=events.js.map