#include <grpcServer.hpp>
gRPC server (HTTP/2) for RpcService : the same services can be installed in an anch-rest API ( installRpc , Connect and gRPC-Web) and in a gRPC server, for native gRPC clients (stubs generated by grpc_cpp_plugin ).
Methods are unary: the first request message is processed. RpcError is sent with its code and message ( UNIMPLEMENTED for unknown methods), request metadata are given in RpcContext , response metadata are sent as initial metadata. Services have to outlive the server.
- Author
- Vincent Lachenal
- Since
- 0.2
◆ GrpcServer() [1/2]
| anch::rest::GrpcServer::GrpcServer |
( |
| ) |
|
◆ GrpcServer() [2/2]
| anch::rest::GrpcServer::GrpcServer |
( |
const GrpcServer & | | ) |
|
|
delete |
◆ ~GrpcServer()
| virtual anch::rest::GrpcServer::~GrpcServer |
( |
| ) |
|
|
virtual |
◆ addService()
Add RPC service (before start )
- Parameters
-
- Returns
this
- Exceptions
-
| std::invalid_argument | when a service with the same name already exists |
◆ builder()
| grpc::ServerBuilder & anch::rest::GrpcServer::builder |
( |
| ) |
|
|
noexcept |
Get gRPC server builder, to set other options (before start )
- Returns
- the builder
◆ getPort()
| int anch::rest::GrpcServer::getPort |
( |
| ) |
const |
|
noexcept |
Get the port of the first listening address
- Returns
- the port,
0 before start
◆ listen()
| GrpcServer & anch::rest::GrpcServer::listen |
( |
const std::string & | address, |
|
|
std::shared_ptr< grpc::ServerCredentials > | credentials = grpc::InsecureServerCredentials() ) |
Add listening address (before start )
- Parameters
-
| address | the address ( 0.0.0.0:50051 , 127.0.0.1:0 for a free port) |
| credentials | the credentials (insecure by default) |
- Returns
this
◆ operator=()
◆ shutdown()
| void anch::rest::GrpcServer::shutdown |
( |
| ) |
|
Shut down server: running calls are completed
◆ start()
| int anch::rest::GrpcServer::start |
( |
| ) |
|
Start server
- Returns
- the port of the first listening address
- Exceptions
-
| std::runtime_error | when server can not be started |
◆ wait()
| void anch::rest::GrpcServer::wait |
( |
| ) |
|
The documentation for this class was generated from the following file: