Skip to content

feat etcd: Init etcd client #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from

Conversation

eskedesu
Copy link


Note: by creating a PR or an issue you automatically agree to the CLA. See CONTRIBUTING.md. Feel free to remove this note, the agreement holds.

#pragma once

#include <chrono>
#include <cstdint>
Copy link
Collaborator

Choose a reason for hiding this comment

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

давай сразу клиента конфига сделаешь до полноценного watch event'а - так будет проще понять, какой API требуется и что еще необходимо сделать

Copy link
Author

@eskedesu eskedesu May 9, 2025

Choose a reason for hiding this comment

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

Кажется, сделал, получать ивенты можно из WatchListener'а

@@ -444,7 +444,7 @@ def _gen_string(

if schema.format:
if schema.format == types.StringFormat.BYTE:
format_cpp_type = 'crypto::base64::String64'
format_cpp_type = '::crypto::base64::String64'
Copy link
Collaborator

Choose a reason for hiding this comment

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

USERVER_NAMESPACE::

@@ -18,9 +18,9 @@ USERVER_NAMESPACE_BEGIN

namespace chaotic::convert {

crypto::base64::String64 Convert(const std::string& str, chaotic::convert::To<crypto::base64::String64>);
::crypto::base64::String64 Convert(const std::string& str, chaotic::convert::To<::crypto::base64::String64>);
Copy link
Collaborator

Choose a reason for hiding this comment

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

USERVER_NAMESPACE::

@@ -369,7 +369,7 @@ TEST(Simple, Uuid) {
}

TEST(SIMPLE, String64) {
auto str64 = crypto::base64::String64{"hello, userver!"};
auto str64 = ::crypto::base64::String64{"hello, userver!"};
Copy link
Collaborator

Choose a reason for hiding this comment

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

USERVER_NAMESPACE::

@@ -54,7 +54,7 @@ def test_byte(simple_gen):
assert types == {
'::type': cpp_types.CppStringWithFormat(
raw_cpp_type=type_name.TypeName('std::string'),
format_cpp_type='crypto::base64::String64',
format_cpp_type='::crypto::base64::String64',
Copy link
Collaborator

Choose a reason for hiding this comment

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

USERVER_NAMESPACE::

WatchListener(concurrent::SpscQueue<KeyValueState>::Consumer&& consumer);

/// @brief Get an event from etcd if there was one, otherwise waits asynchronously until a next event occurs.
/// If the event producing coroutine finished or failed, GetEvent raises EtcdError exception
Copy link
Collaborator

Choose a reason for hiding this comment

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


std::string BuildDeleteData(std::string_view key) {
const auto etcd_key = fmt::format("{}{}", kKeyPrefix, key);
return formats::json::ToString(formats::json::MakeObject("key", crypto::base64::Base64Encode(etcd_key)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

везде где есть base64 - в хаотик


constexpr std::uint32_t kDefaultAttempts{3};
constexpr std::chrono::milliseconds kDefaultRequestTimeout{1'000};
constexpr std::chrono::milliseconds kDefaultWatchTimeout{1'000'000};
Copy link
Collaborator

Choose a reason for hiding this comment

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

1000 секунд всего? а что будет когда истечет?

// Etcd endpoints to which client make HTTP requests
std::vector<std::string> endpoints;
// Number of attempts to each endpoint, on failed attempts client randomly moves to another endpoint
std::uint32_t attempts;
Copy link
Collaborator

Choose a reason for hiding this comment

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

{1}

// Number of attempts to each endpoint, on failed attempts client randomly moves to another endpoint
std::uint32_t attempts;
// Timeout for all HTTP requests to etcd except watch request
std::chrono::microseconds request_timeout_ms;
Copy link
Collaborator

Choose a reason for hiding this comment

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

{дефолт}

std::chrono::microseconds request_timeout_ms;
// Timeout for watch HTTP request. It's a stremed request, so it is used also as a connection timeout, so it should
// not be too short
std::chrono::microseconds watch_timeout_ms;
Copy link
Collaborator

Choose a reason for hiding this comment

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

{дефолт}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants