feat etcd: Init etcd client#837
Open
eskedesu wants to merge 42 commits intouserver-framework:developfrom
Open
Conversation
segoon
reviewed
Jan 20, 2025
segoon
reviewed
Feb 3, 2025
| #pragma once | ||
|
|
||
| #include <chrono> | ||
| #include <cstdint> |
Collaborator
There was a problem hiding this comment.
давай сразу клиента конфига сделаешь до полноценного watch event'а - так будет проще понять, какой API требуется и что еще необходимо сделать
Author
There was a problem hiding this comment.
Кажется, сделал, получать ивенты можно из WatchListener'а
segoon
reviewed
Feb 16, 2025
segoon
reviewed
May 7, 2025
segoon
reviewed
May 15, 2025
segoon
reviewed
May 16, 2025
| if schema.format: | ||
| if schema.format == types.StringFormat.BYTE: | ||
| format_cpp_type = 'crypto::base64::String64' | ||
| format_cpp_type = '::crypto::base64::String64' |
| 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>); |
Author
There was a problem hiding this comment.
Тут внес String64 внутрь и теперь убрал префикс ::, до этого String64 лежал вне юсервисного неймспейса
|
|
||
| TEST(SIMPLE, String64) { | ||
| auto str64 = crypto::base64::String64{"hello, userver!"}; | ||
| auto str64 = ::crypto::base64::String64{"hello, userver!"}; |
Author
There was a problem hiding this comment.
Тут внес 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', |
| 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 |
|
|
||
| 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))); |
Collaborator
There was a problem hiding this comment.
везде где есть base64 - в хаотик
|
|
||
| constexpr std::uint32_t kDefaultAttempts{3}; | ||
| constexpr std::chrono::milliseconds kDefaultRequestTimeout{1'000}; | ||
| constexpr std::chrono::milliseconds kDefaultWatchTimeout{1'000'000}; |
Collaborator
There was a problem hiding this comment.
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; |
| // 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; |
| 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; |
29c17ef to
d3e676c
Compare
d3e676c to
cb883c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.