29#include <unordered_map>
33#if NETWORK_GRPC_OFFICIAL
42class ServerReflectionRequest;
43class ServerReflectionResponse;
127 for (
const auto& method :
methods)
129 if (method.name == method_name)
147 return package + "." + name;
177 virtual auto is_ready() const ->
bool {
return true; }
179#if NETWORK_GRPC_OFFICIAL
184 virtual auto grpc_service() -> ::grpc::Service* {
return nullptr; }
245 auto register_unary_method(
246 const std::
string& method_name,
248 const std::
string& input_type = "",
249 const std::
string& output_type = "") ->
VoidResult;
259 auto register_server_streaming_method(
260 const std::
string& method_name,
262 const std::
string& input_type = "",
263 const std::
string& output_type = "") ->
VoidResult;
273 auto register_client_streaming_method(
274 const std::
string& method_name,
276 const std::
string& input_type = "",
277 const std::
string& output_type = "") ->
VoidResult;
287 auto register_bidi_streaming_method(
288 const std::
string& method_name,
290 const std::
string& input_type = "",
291 const std::
string& output_type = "") ->
VoidResult;
298 auto get_unary_handler(const std::
string& method_name) const
306 auto get_server_streaming_handler(const std::
string& method_name) const
314 auto get_client_streaming_handler(const std::
string& method_name) const
322 auto get_bidi_streaming_handler(const std::
string& method_name) const
325#if NETWORK_GRPC_OFFICIAL
338#if NETWORK_GRPC_OFFICIAL
368 protoc_service_adapter(std::unique_ptr<::grpc::Service> service,
369 std::string service_name);
376 protoc_service_adapter(::grpc::Service* service,
377 std::string service_name);
379 ~protoc_service_adapter()
override;
382 protoc_service_adapter(
const protoc_service_adapter&) =
delete;
383 protoc_service_adapter& operator=(
const protoc_service_adapter&) =
delete;
386 protoc_service_adapter(protoc_service_adapter&&)
noexcept;
387 protoc_service_adapter& operator=(protoc_service_adapter&&)
noexcept;
395 std::unique_ptr<impl> impl_;
411 bool enable_reflection =
false;
414 bool enable_health_check =
false;
417 std::string health_service_name =
"grpc.health.v1.Health";
476 auto unregister_service(const std::
string& service_name) ->
VoidResult;
483 auto find_service(const std::
string& service_name) const ->
service_base*;
495 auto service_names() const -> std::vector<std::
string>;
502 auto find_method(const std::
string& full_method_path) const
509 auto is_reflection_enabled() const ->
bool;
518#if NETWORK_GRPC_OFFICIAL
524 auto configure_server_builder(::grpc::ServerBuilder& builder) ->
VoidResult;
531 auto enable_reflection(::grpc::ServerBuilder& builder) ->
VoidResult;
540 auto set_service_health(
const std::string& service_name,
bool serving)
548 auto get_service_health(
const std::string& service_name)
const -> bool;
599 auto set_status(const std::
string& service_name,
health_status status) ->
void;
606 auto get_status(const std::
string& service_name) const ->
health_status;
611 auto clear() ->
void;
613#if NETWORK_GRPC_OFFICIAL
632 -> std::optional<std::pair<std::string, std::string>>;
641 std::string_view method_name) -> std::string;
A service that allows dynamic method registration.
generic_service(generic_service &&) noexcept
generic_service(const generic_service &)=delete
std::unique_ptr< impl > impl_
generic_service & operator=(const generic_service &)=delete
~generic_service() override
gRPC server for handling RPC requests
Base class for gRPC service implementations.
Implementation of gRPC health checking protocol.
std::unique_ptr< impl > impl_
health_service(const health_service &)=delete
health_service(health_service &&) noexcept
health_service & operator=(const health_service &)=delete
~health_service() override
Base class for all gRPC service implementations.
virtual auto descriptor() const -> const service_descriptor &=0
Get the service descriptor.
virtual ~service_base()=default
Central registry for managing gRPC services.
service_registry & operator=(const service_registry &)=delete
std::unique_ptr< impl > impl_
service_registry(service_registry &&) noexcept
service_registry(const service_registry &)=delete
gRPC protocol implementation
auto parse_method_path(std::string_view full_path) -> std::optional< std::pair< std::string, std::string > >
Parse full method path into service and method names.
health_status
Health status for a service.
@ service_unknown
Service is not registered.
@ not_serving
Service is not serving.
@ serving
Service is serving.
method_type
Type of RPC method.
@ server_streaming
Server streaming (single request, multiple responses)
@ client_streaming
Client streaming (multiple requests, single response)
@ bidi_streaming
Bidirectional streaming (multiple requests and responses)
@ unary
Unary RPC (single request, single response)
std::function< std::pair< grpc_status, std::vector< uint8_t > >( server_context &ctx, const std::vector< uint8_t > &request)> unary_handler
Handler function type for unary RPC.
auto build_method_path(std::string_view service_name, std::string_view method_name) -> std::string
Build full method path from service and method names.
std::function< grpc_status( server_context &ctx, const std::vector< uint8_t > &request, server_writer &writer)> server_streaming_handler
Handler function type for server streaming RPC.
std::function< grpc_status( server_context &ctx, server_reader_writer &stream)> bidi_streaming_handler
Handler function type for bidirectional streaming RPC.
std::function< std::pair< grpc_status, std::vector< uint8_t > >( server_context &ctx, server_reader &reader)> client_streaming_handler
Handler function type for client streaming RPC.
Network-specific error and result type definitions.
gRPC server configuration and service hosting.
gRPC status codes and error representation.
Describes a single RPC method within a service.
std::string output_type
Output message type name (for reflection)
std::string input_type
Input message type name (for reflection)
std::string full_name
Full method path (e.g., "/package.Service/Method")
auto is_server_streaming() const -> bool
Whether the method provides server streaming.
method_type type
Type of RPC method.
std::string name
Method name (without service prefix)
auto is_client_streaming() const -> bool
Whether the method requires client streaming.
Configuration for service registry.
Describes a gRPC service and its methods.
auto full_name() const -> std::string
Get full service name including package.
std::vector< method_descriptor > methods
List of methods in this service.
std::string name
Service name (e.g., "helloworld.Greeter")
std::string package
Package name (e.g., "helloworld")
auto find_method(std::string_view method_name) const -> const method_descriptor *
Find a method by name.