Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ydb/include/userver/ydb/coordination.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class CoordinationSession final {
);

/// Create semaphore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add a description for data parameter

void CreateSemaphore(std::string_view name, std::uint64_t limit);
void CreateSemaphore(std::string_view name, std::uint64_t limit, std::string_view data = {});

/// Update semaphore
void UpdateSemaphore(std::string_view name, std::string_view data);

/// Delete semaphore
void DeleteSemaphore(std::string_view name);
void DeleteSemaphore(std::string_view name, bool force = false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use enum instead of bool. With enums the code becomes more readable:

x.DeleteSemaphore("foo", true);

vs

x.DeleteSemaphore("foo", Mode::kForce);


private:
NYdb::NCoordination::TSession session_;
Expand Down
8 changes: 4 additions & 4 deletions ydb/src/ydb/coordination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ NYdb::NCoordination::TSemaphoreDescription CoordinationSession::DescribeSemaphor
return ExtractResult(session_.DescribeSemaphore(impl::ToString(name), settings), "DescribeSemaphore");
}

void CoordinationSession::CreateSemaphore(std::string_view name, std::uint64_t limit) {
ExtractResult(session_.CreateSemaphore(impl::ToString(name), limit), "CreateSemaphore");
void CoordinationSession::CreateSemaphore(std::string_view name, std::uint64_t limit, std::string_view data) {
ExtractResult(session_.CreateSemaphore(impl::ToString(name), limit, impl::ToString(data)), "CreateSemaphore");
}

void CoordinationSession::UpdateSemaphore(std::string_view name, std::string_view data) {
ExtractResult(session_.UpdateSemaphore(impl::ToString(name), impl::ToString(data)), "UpdateSemaphore");
}

void CoordinationSession::DeleteSemaphore(std::string_view name) {
ExtractResult(session_.DeleteSemaphore(impl::ToString(name)), "DeleteSemaphore");
void CoordinationSession::DeleteSemaphore(std::string_view name, bool force) {
ExtractResult(session_.DeleteSemaphore(impl::ToString(name), force), "DeleteSemaphore");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for the both additions

}

CoordinationClient::CoordinationClient(std::shared_ptr<impl::Driver> driver)
Expand Down
Loading