From 672f26218883f4a1f9ebb3da8480e7e105f935be Mon Sep 17 00:00:00 2001 From: kpavlov00 Date: Wed, 18 Dec 2024 13:57:03 +0300 Subject: [PATCH] feat ydb: upd coordination docs commit_hash:e86fd7ca18f8351f5debc9d44577a2efa2c64cd3 --- ydb/include/userver/ydb/coordination.hpp | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ydb/include/userver/ydb/coordination.hpp b/ydb/include/userver/ydb/coordination.hpp index 9bcbad6751f6..9c7af5ac84dc 100644 --- a/ydb/include/userver/ydb/coordination.hpp +++ b/ydb/include/userver/ydb/coordination.hpp @@ -1,5 +1,8 @@ #pragma once +/// @file userver/ydb/coordination.hpp +/// @brief YDB Coordination client + #include #include @@ -13,6 +16,9 @@ namespace impl { class Driver; } // namespace impl +/// @brief Coordination Session +/// +/// @see https://ydb.tech/docs/ru/reference/ydb-sdk/coordination#session class CoordinationSession final { public: /// @cond @@ -20,39 +26,57 @@ class CoordinationSession final { explicit CoordinationSession(NYdb::NCoordination::TSession&& session); /// @endcond + /// Get session id std::uint64_t GetSessionId(); + /// Get session state NYdb::NCoordination::ESessionState GetSessionState(); + /// Get connection state NYdb::NCoordination::EConnectionState GetConnectionState(); + /// Close session void Close(); + /// Ping void Ping(); + /// Reconnect session void Reconnect(); + /// Acquire semaphore /// @warning Use `TAcquireSemaphoreSettings::OnAccepted` callback with care, /// it will be executed on a non-coroutine thread bool AcquireSemaphore(std::string_view name, const NYdb::NCoordination::TAcquireSemaphoreSettings& settings); + /// Release semaphore bool ReleaseSemaphore(std::string_view name); + /// Describe semaphore /// @warning Use `TDescribeSemaphoreSettings::OnChanged` callback with care, /// it will be executed on a non-coroutine thread NYdb::NCoordination::TSemaphoreDescription DescribeSemaphore(std::string_view name, const NYdb::NCoordination::TDescribeSemaphoreSettings& settings); + /// Create semaphore void CreateSemaphore(std::string_view name, std::uint64_t limit); + /// Update semaphore void UpdateSemaphore(std::string_view name, std::string_view data); + /// Delete semaphore void DeleteSemaphore(std::string_view name); private: NYdb::NCoordination::TSession session_; }; +/// @ingroup userver_clients +/// +/// @brief YDB Coordination Client +/// +/// Provides access to work with Coordination Service +/// @see https://ydb.tech/docs/ru/reference/ydb-sdk/coordination class CoordinationClient final { public: /// @cond @@ -60,17 +84,22 @@ class CoordinationClient final { explicit CoordinationClient(std::shared_ptr driver); /// @endcond + /// Start session /// @warning Use `TSessionSettings::OnStateChanged` and /// `TSessionSettings::OnStopped` callbacks with care, they will be executed /// on a non-coroutine thread CoordinationSession StartSession(std::string_view path, const NYdb::NCoordination::TSessionSettings& settings); + /// Create coordination node void CreateNode(std::string_view path, const NYdb::NCoordination::TCreateNodeSettings& settings); + /// Alter coordination node void AlterNode(std::string_view path, const NYdb::NCoordination::TAlterNodeSettings& settings); + /// Drop coordination node void DropNode(std::string_view path); + /// Describe coordination node NYdb::NCoordination::TNodeDescription DescribeNode(std::string_view path); /// Get native coordination client