10#include <userver/dynamic_config/snapshot.hpp>
11#include <userver/dynamic_config/storage_mock.hpp>
12#include <userver/dynamic_config/test_helpers.hpp>
13#include <userver/utils/statistics/storage.hpp>
15#include <userver/ugrpc/client/client_factory.hpp>
16#include <userver/ugrpc/server/server.hpp>
17#include <userver/ugrpc/server/service_base.hpp>
19USERVER_NAMESPACE_BEGIN
33 explicit ServiceBase(
server::ServerConfig&& server_config);
37 virtual ~ServiceBase();
55 template <
typename Client>
57 return GetClientFactory().MakeClient<Client>(
"test", *endpoint_);
68 client::MiddlewareFactories middleware_factories);
83 client::ClientFactory& GetClientFactory();
86 std::string GetEndpoint()
const;
90 server::ServiceConfig MakeServiceConfig();
92 utils::statistics::Storage statistics_storage_;
93 dynamic_config::StorageMock config_storage_;
94 std::optional<std::string> unix_socket_path_;
96 server::Middlewares server_middlewares_;
97 client::MiddlewareFactories client_middleware_factories_;
98 bool middlewares_change_allowed_{
true};
100 std::optional<std::string> endpoint_;
101 ugrpc::impl::StatisticsStorage client_statistics_storage_;
102 std::optional<
client::ClientFactory> client_factory_;
113template <
typename GrpcService>
120 template <
typename... Args>
121 explicit Service(std::in_place_t, Args&&... args)
122 :
Service(server::ServerConfig{}, std::in_place,
123 std::forward<Args>(args)...) {}
126 template <
typename... Args>
127 Service(
server::ServerConfig&& server_config, std::in_place_t = std::in_place,
130 service_(std::forward<Args>(args)...) {
131 SetServerMiddlewares(GetDefaultServerMiddlewares());
132 SetClientMiddlewareFactories(GetDefaultClientMiddlewareFactories());
133 RegisterService(service_);
143 GrpcService service_{};