#include <userver/ugrpc/server/server.hpp>
Manages the gRPC server.
All methods are thread-safe. Usually retrieved from ugrpc::server::ServerComponent.
Definition at line 64 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.
|
|
std::vector< std::string_view > | GetServiceNames () const |
| Get names of all registered services.
|
|
void | WithServerBuilder (SetupHook setup) |
| For advanced configuration of the gRPC server.
|
|
grpc::CompletionQueue & | GetCompletionQueue () noexcept |
|
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 |
|
std::uint64_t | GetTotalRequests () const override |
|
◆ SetupHook
using ugrpc::server::Server::SetupHook = utils::function_ref<void(grpc::ServerBuilder&)> |
◆ GetCompletionQueue()
grpc::CompletionQueue & ugrpc::server::Server::GetCompletionQueue |
( |
| ) |
|
|
noexcept |
- Returns
- the completion queue for clients
- Note
- All RPCs are cancelled on 'Stop'. If you need to perform requests after the server has been closed, create an ugrpc::client::QueueHolder - usually no more than one instance per program.
◆ GetPort()
int ugrpc::server::Server::GetPort |
( |
| ) |
const |
|
noexcept |
- Returns
- The port assigned using
AddListeningPort
- Note
- Only available after 'Start' has returned
◆ GetTotalRequests()
std::uint64_t ugrpc::server::Server::GetTotalRequests |
( |
| ) |
const |
|
overridevirtual |
◆ 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: