userver: ugrpc::tests::Service< GrpcService > Class Template Reference
Loading...
Searching...
No Matches
ugrpc::tests::Service< GrpcService > Class Template Reference

#include <userver/ugrpc/tests/service.hpp>

Detailed Description

template<typename GrpcService>
class ugrpc::tests::Service< GrpcService >

Sets up a mini gRPC server using a single service implementation.

See also
ugrpc::tests::ServiceBase

Definition at line 104 of file service.hpp.

+ Inheritance diagram for ugrpc::tests::Service< GrpcService >:

Public Member Functions

 Service ()
 Default-constructs the service.
 
template<typename... Args>
 Service (std::in_place_t, Args &&... args)
 Passes args to the service.
 
template<typename... Args>
 Service (server::ServerConfig &&server_config, std::in_place_t=std::in_place, Args &&... args)
 Passes args to the service.
 
GrpcService & GetService ()
 
void RegisterService (server::ServiceBase &service)
 
void RegisterService (server::GenericServiceBase &service)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void StartServer (client::ClientFactorySettings &&settings={})
 
void StopServer () noexcept
 
template<typename Client >
Client MakeClient ()
 
server::ServerGetServer () noexcept
 
void SetServerMiddlewares (server::Middlewares middlewares)
 Server middlewares can be modified before the first RegisterService call.
 
void SetClientMiddlewareFactories (client::MiddlewareFactories middleware_factories)
 Client middlewares can be modified before the first RegisterService call.
 
void ExtendDynamicConfig (const std::vector< dynamic_config::KeyValue > &)
 
dynamic_config::Source GetConfigSource () const
 
utils::statistics::StorageGetStatisticsStorage ()
 

Constructor & Destructor Documentation

◆ Service() [1/3]

template<typename GrpcService >
ugrpc::tests::Service< GrpcService >::Service ( )
inline

Default-constructs the service.

Definition at line 107 of file service.hpp.

◆ Service() [2/3]

template<typename GrpcService >
template<typename... Args>
ugrpc::tests::Service< GrpcService >::Service ( std::in_place_t ,
Args &&... args )
inlineexplicit

Passes args to the service.

Definition at line 111 of file service.hpp.

◆ Service() [3/3]

template<typename GrpcService >
template<typename... Args>
ugrpc::tests::Service< GrpcService >::Service ( server::ServerConfig && server_config,
std::in_place_t = std::in_place,
Args &&... args )
inline

Passes args to the service.

Definition at line 117 of file service.hpp.

◆ ~Service()

template<typename GrpcService >
ugrpc::tests::Service< GrpcService >::~Service ( )
inlineoverride

Definition at line 127 of file service.hpp.

Member Function Documentation

◆ ExtendDynamicConfig()

void ugrpc::tests::ServiceBase::ExtendDynamicConfig ( const std::vector< dynamic_config::KeyValue > & )
inherited

Modifies the internal dynamic configs storage. It is used by the server and clients, and is accessible through GetConfigSource. Initially, the configs are filled with compile-time defaults.

◆ GetConfigSource()

dynamic_config::Source ugrpc::tests::ServiceBase::GetConfigSource ( ) const
inherited
Returns
the dynamic configs affected by ExtendDynamicConfig.

◆ GetServer()

server::Server & ugrpc::tests::ServiceBase::GetServer ( )
noexceptinherited
Returns
the stored server::Server for advanced tweaking.

◆ GetService()

template<typename GrpcService >
GrpcService & ugrpc::tests::Service< GrpcService >::GetService ( )
inline
Returns
the stored service.

Definition at line 130 of file service.hpp.

◆ GetStatisticsStorage()

utils::statistics::Storage & ugrpc::tests::ServiceBase::GetStatisticsStorage ( )
inherited
Returns
the statistics storage used by the server and clients.

◆ MakeClient()

template<typename Client >
Client ugrpc::tests::ServiceBase::MakeClient ( )
inlineinherited
Returns
a client for the specified gRPC service, connected to the server.

Definition at line 56 of file service.hpp.

◆ RegisterService()

void ugrpc::tests::ServiceBase::RegisterService ( server::ServiceBase & service)
inherited

Register a gRPC service implementation. The caller owns the service and should ensure that the services live at least until StopServer is called.

◆ StartServer()

void ugrpc::tests::ServiceBase::StartServer ( client::ClientFactorySettings && settings = {})
inherited

Starts the server and connects a grpc channel to it. Should be called after the services are registered.

◆ StopServer()

void ugrpc::tests::ServiceBase::StopServer ( )
noexceptinherited

Should be called before the registered services are destroyed. Should typically be called in the destructor of your gtest fixture.


The documentation for this class was generated from the following file: