heartbeat_failed_event.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/stdx/string_view.hpp>
  16. #include <mongocxx/config/prelude.hpp>
  17. namespace mongocxx {
  18. MONGOCXX_INLINE_NAMESPACE_BEGIN
  19. namespace events {
  20. ///
  21. /// An event notification sent when the driver failed to send an "isMaster" command to check the
  22. /// status of a server.
  23. ///
  24. /// @see "ServerHeartbeatFailedEvent" in
  25. /// https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst
  26. ///
  27. class MONGOCXX_API heartbeat_failed_event {
  28. public:
  29. MONGOCXX_PRIVATE explicit heartbeat_failed_event(const void* event);
  30. ///
  31. /// Destroys a heartbeat_failed_event.
  32. ///
  33. ~heartbeat_failed_event();
  34. ///
  35. /// Returns the failed operation's error message.
  36. ///
  37. /// @return The message.
  38. ///
  39. std::string message() const;
  40. ///
  41. /// Returns the duration of the failed operation.
  42. ///
  43. /// @return The duration in microseconds.
  44. ///
  45. std::int64_t duration() const;
  46. ///
  47. /// Returns the host name.
  48. ///
  49. /// @return The host name.
  50. ///
  51. bsoncxx::stdx::string_view host() const;
  52. ///
  53. /// Returns the port.
  54. ///
  55. /// @return The port.
  56. ///
  57. std::uint16_t port() const;
  58. ///
  59. /// Returns a boolean indicating whether this heartbeat event is from an awaitable isMaster.
  60. ///
  61. /// @return A boolean.
  62. ///
  63. bool awaited() const;
  64. private:
  65. const void* _failed_event;
  66. };
  67. } // namespace events
  68. MONGOCXX_INLINE_NAMESPACE_END
  69. } // namespace mongocxx
  70. #include <mongocxx/config/postlude.hpp>