Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::server::GrpcServer Class Reference

A thin wrapper that runs gRPC services next to an Orbit App. More...

#include <GrpcServer.hpp>

Public Member Functions

 GrpcServer ()
 
 ~GrpcServer ()
 
void add_service (grpc::Service *service)
 Registers a service; it must outlive the server. Call before start().
 
void start (const std::string &address)
 
int port () const
 The port listened on once started, e.g. the one chosen for port 0.
 
void stop ()
 

Private Attributes

int port_ = 0
 

Detailed Description

A thin wrapper that runs gRPC services next to an Orbit App.

Warning
Experimental. It is a minimal pass-through to grpc::ServerBuilder (insecure credentials only, no TLS, no options) and is not covered by the main CI matrix; see issue #22. Build with -DORBIT_ENABLE_GRPC=ON. Without it, add_service() and start() throw, rather than pretending to serve.

gRPC enables SO_REUSEPORT on Linux, so two servers (or two processes, as during App::hot_reload()) can listen on the same address and share its connections.

Constructor & Destructor Documentation

◆ GrpcServer()

orbit::server::GrpcServer::GrpcServer ( )

◆ ~GrpcServer()

orbit::server::GrpcServer::~GrpcServer ( )

Member Function Documentation

◆ add_service()

void orbit::server::GrpcServer::add_service ( grpc::Service *  service)

Registers a service; it must outlive the server. Call before start().

◆ port()

int orbit::server::GrpcServer::port ( ) const
inline

The port listened on once started, e.g. the one chosen for port 0.

◆ start()

void orbit::server::GrpcServer::start ( const std::string &  address)

Starts serving on address ("host:port"; port 0 picks a free one).

Exceptions
std::runtime_errorif the server could not be started.

◆ stop()

void orbit::server::GrpcServer::stop ( )

Member Data Documentation

◆ port_

int orbit::server::GrpcServer::port_ = 0
private

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