events.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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) {
  93. this.connectionId = connectionId;
  94. }
  95. }
  96. exports.ServerHeartbeatStartedEvent = ServerHeartbeatStartedEvent;
  97. /**
  98. * Emitted when the server monitor’s hello succeeds.
  99. * @public
  100. * @category Event
  101. */
  102. class ServerHeartbeatSucceededEvent {
  103. /** @internal */
  104. constructor(connectionId, duration, reply) {
  105. this.connectionId = connectionId;
  106. this.duration = duration;
  107. this.reply = reply !== null && reply !== void 0 ? reply : {};
  108. }
  109. }
  110. exports.ServerHeartbeatSucceededEvent = ServerHeartbeatSucceededEvent;
  111. /**
  112. * Emitted when the server monitor’s hello fails, either with an “ok: 0” or a socket exception.
  113. * @public
  114. * @category Event
  115. */
  116. class ServerHeartbeatFailedEvent {
  117. /** @internal */
  118. constructor(connectionId, duration, failure) {
  119. this.connectionId = connectionId;
  120. this.duration = duration;
  121. this.failure = failure;
  122. }
  123. }
  124. exports.ServerHeartbeatFailedEvent = ServerHeartbeatFailedEvent;
  125. //# sourceMappingURL=events.js.map