heartbeat_succeeded_event.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2018-present MongoDB Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <bsoncxx/document/view.hpp>
  16. #include <bsoncxx/stdx/string_view.hpp>
  17. #include <mongocxx/config/prelude.hpp>
  18. namespace mongocxx {
  19. MONGOCXX_INLINE_NAMESPACE_BEGIN
  20. namespace events {
  21. ///
  22. /// An event notification sent when the driver completes an "isMaster" command to check the status
  23. /// of a server.
  24. ///
  25. /// @see "ServerHeartbeatSucceededEvent" in
  26. /// https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst
  27. ///
  28. class MONGOCXX_API heartbeat_succeeded_event {
  29. public:
  30. MONGOCXX_PRIVATE explicit heartbeat_succeeded_event(const void* event);
  31. ///
  32. /// Destroys a heartbeat_succeeded_event.
  33. ///
  34. ~heartbeat_succeeded_event();
  35. ///
  36. /// Returns the server reply for the succeeded operation.
  37. ///
  38. /// @return The reply.
  39. ///
  40. bsoncxx::document::view reply() const;
  41. ///
  42. /// Returns the duration of the successful operation.
  43. ///
  44. /// @return The duration in microseconds.
  45. ///
  46. std::int64_t duration() const;
  47. ///
  48. /// Returns the host name.
  49. ///
  50. /// @return The host name.
  51. ///
  52. bsoncxx::stdx::string_view host() const;
  53. ///
  54. /// Returns the port.
  55. ///
  56. /// @return The port.
  57. ///
  58. std::uint16_t port() const;
  59. ///
  60. /// Returns a boolean indicating whether this heartbeat event is from an awaitable isMaster.
  61. ///
  62. /// @return A boolean.
  63. ///
  64. bool awaited() const;
  65. private:
  66. const void* _succeeded_event;
  67. };
  68. } // namespace events
  69. MONGOCXX_INLINE_NAMESPACE_END
  70. } // namespace mongocxx
  71. #include <mongocxx/config/postlude.hpp>