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_);
82 client::ClientFactory& GetClientFactory();
85 std::string GetEndpoint()
const;
89 server::ServiceConfig MakeServiceConfig();
91 utils::statistics::Storage statistics_storage_;
92 dynamic_config::StorageMock config_storage_;
93 std::optional<std::string> unix_socket_path_;
95 server::Middlewares server_middlewares_;
96 client::MiddlewareFactories client_middleware_factories_;
97 bool middlewares_change_allowed_{
true};
99 std::optional<std::string> endpoint_;
100 ugrpc::impl::StatisticsStorage client_statistics_storage_;
101 std::optional<
client::ClientFactory> client_factory_;
112template <
typename GrpcService>
119 template <
typename... Args>
120 explicit Service(std::in_place_t, Args&&... args)
121 :
Service(server::ServerConfig{}, std::in_place, std::forward<Args>(args)...) {}
124 template <
typename... Args>
125 Service(
server::ServerConfig&& server_config, std::in_place_t = std::in_place, Args&&... args)
126 :
ServiceBase(std::move(server_config)), service_(std::forward<Args>(args)...) {
127 SetServerMiddlewares(GetDefaultServerMiddlewares());
128 SetClientMiddlewareFactories(GetDefaultClientMiddlewareFactories());
129 RegisterService(service_);
139 GrpcService service_{};