-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit_hash:68737ed9ce03b32c0f093cea5ba3e97bd7552cac
- Loading branch information
Showing
24 changed files
with
235 additions
and
161 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#pragma once | ||
|
||
/// @file userver/ugrpc/client/client_settings.hpp | ||
/// @brief @copybrief ugrpc::client::ClientSettings | ||
|
||
#include <cstddef> | ||
#include <string> | ||
#include <unordered_map> | ||
|
||
#include <userver/dynamic_config/snapshot.hpp> | ||
|
||
#include <userver/ugrpc/client/fwd.hpp> | ||
|
||
USERVER_NAMESPACE_BEGIN | ||
|
||
namespace ugrpc::client { | ||
|
||
// rpc method name -> count of channels | ||
using DedicatedMethodsConfig = std::unordered_map<std::string, std::size_t>; | ||
|
||
/// Settings relating to creation of a code-generated client | ||
struct ClientSettings final { | ||
/// **(Required)** | ||
/// The name of the client, for diagnostics, credentials and middlewares. | ||
std::string client_name; | ||
|
||
/// **(Required)** | ||
/// The URI to connect to, e.g. `http://my.domain.com:8080`. | ||
/// Should not include any HTTP path, just schema, domain name and port. Unix | ||
/// sockets are also supported. For details, see: | ||
/// https://grpc.github.io/grpc/cpp/md_doc_naming.html | ||
std::string endpoint; | ||
|
||
/// **(Optional)** | ||
/// The name of the QOS | ||
/// @ref scripts/docs/en/userver/dynamic_config.md "dynamic config" | ||
/// that will be applied automatically to every RPC. | ||
/// | ||
/// Timeout from QOS config is ignored if: | ||
/// | ||
/// * an explicit `qos` parameter is specified at RPC creation, or | ||
/// * deadline is specified in the `client_context` passed at RPC creation. | ||
/// | ||
/// ## Client QOS config definition sample | ||
/// | ||
/// @snippet grpc/tests/tests/unit_test_client_qos.hpp qos config key | ||
const dynamic_config::Key<ClientQos>* client_qos{nullptr}; | ||
|
||
/// **(Optional)** | ||
/// Dedicated high-load methods that have separate channels | ||
DedicatedMethodsConfig dedicated_methods_config{}; | ||
}; | ||
|
||
std::size_t GetMethodChannelCount(const DedicatedMethodsConfig& dedicated_methods_config, std::string_view method_name); | ||
|
||
} // namespace ugrpc::client | ||
|
||
USERVER_NAMESPACE_END |
2 changes: 1 addition & 1 deletion
2
.../include/userver/ugrpc/client/generic.hpp → ...e/userver/ugrpc/client/generic_client.hpp
This file contains 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
49 changes: 49 additions & 0 deletions
49
grpc/include/userver/ugrpc/client/impl/channel_factory.hpp
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <grpcpp/channel.h> | ||
#include <grpcpp/create_channel.h> | ||
#include <grpcpp/security/credentials.h> | ||
#include <grpcpp/support/channel_arguments.h> | ||
|
||
#include <userver/engine/async.hpp> | ||
|
||
#include <userver/ugrpc/impl/to_string.hpp> | ||
|
||
USERVER_NAMESPACE_BEGIN | ||
|
||
namespace ugrpc::client::impl { | ||
|
||
class ChannelFactory final { | ||
public: | ||
ChannelFactory( | ||
engine::TaskProcessor& blocking_task_processor, | ||
const std::string& endpoint, | ||
std::shared_ptr<grpc::ChannelCredentials> credentials, | ||
const grpc::ChannelArguments& channel_args | ||
) | ||
: blocking_task_processor_(blocking_task_processor), | ||
endpoint_{ugrpc::impl::ToGrpcString(endpoint)}, | ||
credentials_{std::move(credentials)}, | ||
channel_args_{channel_args} {} | ||
|
||
std::shared_ptr<grpc::Channel> CreateChannel() const { | ||
return engine::AsyncNoSpan( | ||
blocking_task_processor_, | ||
grpc::CreateCustomChannel, | ||
std::ref(endpoint_), | ||
std::ref(credentials_), | ||
std::ref(channel_args_) | ||
) | ||
.Get(); | ||
} | ||
|
||
private: | ||
engine::TaskProcessor& blocking_task_processor_; | ||
grpc::string endpoint_; | ||
std::shared_ptr<grpc::ChannelCredentials> credentials_; | ||
const grpc::ChannelArguments& channel_args_; | ||
}; | ||
|
||
} // namespace ugrpc::client::impl | ||
|
||
USERVER_NAMESPACE_END |
This file contains 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
This file contains 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
Oops, something went wrong.