#include <userver/ugrpc/server/server.hpp>
Manages the gRPC server.
All methods are thread-safe. Usually retrieved from ugrpc::server::ServerComponent.
Definition at line 85 of file server.hpp.
|
using | SetupHook = utils::function_ref<void(grpc::ServerBuilder&)> |
|
|
| Server (ServerConfig &&config, utils::statistics::Storage &statistics_storage, dynamic_config::Source config_source) |
| Start building the server.
|
|
| Server (Server &&)=delete |
|
Server & | operator= (Server &&)=delete |
|
void | AddService (ServiceBase &service, ServiceConfig &&config) |
| Register a service implementation in the server. The user or the component is responsible for keeping service and middlewares alive at least until Stop is called.
|
|
void | AddService (GenericServiceBase &service, ServiceConfig &&config) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
|
std::vector< std::string_view > | GetServiceNames () const |
| Get names of all registered services.
|
|
void | WithServerBuilder (SetupHook setup) |
| For advanced configuration of the gRPC server.
|
|
void | Start () |
| Start accepting requests.
|
|
int | GetPort () const noexcept |
|
void | Stop () noexcept |
| Stop accepting requests. Also destroys server statistics and closes the associated CompletionQueue.
|
|
void | StopServing () noexcept |
|
virtual std::uint64_t | GetTotalRequests () const =0 |
|
◆ SetupHook
using ugrpc::server::Server::SetupHook = utils::function_ref<void(grpc::ServerBuilder&)> |
◆ GetPort()
int ugrpc::server::Server::GetPort |
( |
| ) |
const |
|
noexcept |
- Returns
- The port assigned using
AddListeningPort
- Note
- Only available after 'Start' has returned
◆ Start()
void ugrpc::server::Server::Start |
( |
| ) |
|
Start accepting requests.
- Note
- Must be called at most once after all the services are registered
◆ Stop()
void ugrpc::server::Server::Stop |
( |
| ) |
|
|
noexcept |
Stop accepting requests. Also destroys server statistics and closes the associated CompletionQueue.
- Note
- Should be called at least once before the services are destroyed
◆ StopServing()
void ugrpc::server::Server::StopServing |
( |
| ) |
|
|
noexcept |
Same as Stop, but:
- does not destroy server statistics
- does not close the associated CompletionQueue Stop must still be called. StopServing is also useful for testing.
◆ WithServerBuilder()
void ugrpc::server::Server::WithServerBuilder |
( |
SetupHook | setup | ) |
|
For advanced configuration of the gRPC server.
- Note
- The ServerBuilder must not be stored and used outside of
setup
.
The documentation for this class was generated from the following file: