Skip to content

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'а

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::

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::

Copy link
Author

Choose a reason for hiding this comment

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

Тут внес String64 внутрь и теперь убрал префикс ::, до этого String64 лежал вне юсервисного неймспейса


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::

Copy link
Author

Choose a reason for hiding this comment

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

Тут внес String64 внутрь и теперь убрал префикс ::, до этого String64 лежал вне юсервисного неймспейса

'::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::

Copy link
Author

Choose a reason for hiding this comment

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

Добавил

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.

Copy link
Author

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