Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::protocols::grpc::service_registry Class Reference

Central registry for managing gRPC services. More...

#include <service_registry.h>

Collaboration diagram for kcenon::network::protocols::grpc::service_registry:
Collaboration graph

Classes

class  impl
 

Public Member Functions

 service_registry (const registry_config &config={})
 Construct service registry.
 
 ~service_registry ()
 
 service_registry (const service_registry &)=delete
 
service_registryoperator= (const service_registry &)=delete
 
 service_registry (service_registry &&) noexcept
 
service_registryoperator= (service_registry &&) noexcept
 
auto register_service (service_base *service) -> VoidResult
 Register a service.
 
auto unregister_service (const std::string &service_name) -> VoidResult
 Unregister a service.
 
auto find_service (const std::string &service_name) const -> service_base *
 Find a service by name.
 
auto services () const -> std::vector< service_base * >
 Get all registered services.
 
auto service_names () const -> std::vector< std::string >
 Get list of all service names.
 
auto find_method (const std::string &full_method_path) const -> std::optional< std::pair< service_base *, const method_descriptor * > >
 Find a method by full path.
 
auto is_reflection_enabled () const -> bool
 Check if reflection is enabled.
 
auto configure_server (grpc_server &server) -> VoidResult
 Configure a gRPC server with registered services.
 
auto set_service_health (const std::string &service_name, bool serving) -> VoidResult
 Set health status for a service.
 
auto get_service_health (const std::string &service_name) const -> bool
 Get health status for a service.
 

Private Attributes

std::unique_ptr< implimpl_
 

Detailed Description

Central registry for managing gRPC services.

The service registry manages all registered services and provides:

  • Service registration and lookup
  • Method routing
  • Reflection support for debugging tools
  • Health checking integration

Example:

service_registry registry({.enable_reflection = true});
// Register services
generic_service echo_service("echo.EchoService");
echo_service.register_unary_method("Echo", echo_handler);
registry.register_service(&echo_service);
// Use with gRPC server
grpc_server server;
registry.configure_server(server);
server.start(50051);
A service that allows dynamic method registration.
gRPC server for handling RPC requests
Definition server.h:273
Central registry for managing gRPC services.

Definition at line 445 of file service_registry.h.

Constructor & Destructor Documentation

◆ service_registry() [1/3]

kcenon::network::protocols::grpc::service_registry::service_registry ( const registry_config & config = {})
explicit

Construct service registry.

Parameters
configRegistry configuration

Definition at line 716 of file service_registry.cpp.

717 : impl_(std::make_unique<impl>(config))
718{
719}

References config.

◆ ~service_registry()

kcenon::network::protocols::grpc::service_registry::~service_registry ( )
default

◆ service_registry() [2/3]

kcenon::network::protocols::grpc::service_registry::service_registry ( const service_registry & )
delete

◆ service_registry() [3/3]

kcenon::network::protocols::grpc::service_registry::service_registry ( service_registry && )
defaultnoexcept

Member Function Documentation

◆ configure_server()

auto kcenon::network::protocols::grpc::service_registry::configure_server ( grpc_server & server) -> VoidResult

Configure a gRPC server with registered services.

Parameters
serverServer to configure
Returns
Success or error

Definition at line 763 of file service_registry.cpp.

764{
765 return impl_->configure_server(server);
766}
auto configure_server(grpc_server &server) -> VoidResult

◆ find_method()

auto kcenon::network::protocols::grpc::service_registry::find_method ( const std::string & full_method_path) const -> std::optional<std::pair<service_base*, const method_descriptor*>>

Find a method by full path.

Parameters
full_method_pathFull method path (e.g., "/package.Service/Method")
Returns
Pair of service and method descriptor, or nullopt

Definition at line 752 of file service_registry.cpp.

754{
755 return impl_->find_method(full_method_path);
756}
auto find_method(const std::string &full_method_path) const -> std::optional< std::pair< service_base *, const method_descriptor * > >

◆ find_service()

auto kcenon::network::protocols::grpc::service_registry::find_service ( const std::string & service_name) const -> service_base*

Find a service by name.

Parameters
service_nameFull service name
Returns
Pointer to service or nullptr

Definition at line 736 of file service_registry.cpp.

738{
739 return impl_->find_service(service_name);
740}
auto find_service(const std::string &service_name) const -> service_base *

◆ get_service_health()

auto kcenon::network::protocols::grpc::service_registry::get_service_health ( const std::string & service_name) const -> bool

Get health status for a service.

Parameters
service_nameService name (empty for server-wide status)
Returns
True if serving, false otherwise

Definition at line 788 of file service_registry.cpp.

790{
791 return impl_->get_service_health(service_name);
792}
auto get_service_health(const std::string &service_name) const -> bool

◆ is_reflection_enabled()

auto kcenon::network::protocols::grpc::service_registry::is_reflection_enabled ( ) const -> bool

Check if reflection is enabled.

Returns
True if reflection is enabled

Definition at line 758 of file service_registry.cpp.

References impl_, and kcenon::network::protocols::grpc::service_registry::impl::is_reflection_enabled().

Here is the call graph for this function:

◆ operator=() [1/2]

service_registry & kcenon::network::protocols::grpc::service_registry::operator= ( const service_registry & )
delete

◆ operator=() [2/2]

service_registry & kcenon::network::protocols::grpc::service_registry::operator= ( service_registry && )
defaultnoexcept

◆ register_service()

auto kcenon::network::protocols::grpc::service_registry::register_service ( service_base * service) -> VoidResult

Register a service.

Parameters
serviceService to register (registry does not take ownership)
Returns
Success or error

Definition at line 726 of file service_registry.cpp.

727{
728 return impl_->register_service(service);
729}
auto register_service(service_base *service) -> VoidResult

◆ service_names()

auto kcenon::network::protocols::grpc::service_registry::service_names ( ) const -> std::vector<std::string>

Get list of all service names.

Returns
List of service names

Definition at line 747 of file service_registry.cpp.

748{
749 return impl_->service_names();
750}
auto service_names() const -> std::vector< std::string >

References impl_, and kcenon::network::protocols::grpc::service_registry::impl::service_names().

Here is the call graph for this function:

◆ services()

auto kcenon::network::protocols::grpc::service_registry::services ( ) const -> std::vector<service_base*>

Get all registered services.

Returns
List of registered services

Definition at line 742 of file service_registry.cpp.

743{
744 return impl_->services();
745}
auto services() const -> std::vector< service_base * >

References impl_, and kcenon::network::protocols::grpc::service_registry::impl::services().

Here is the call graph for this function:

◆ set_service_health()

auto kcenon::network::protocols::grpc::service_registry::set_service_health ( const std::string & service_name,
bool serving ) -> VoidResult

Set health status for a service.

Parameters
service_nameService name (empty for server-wide status)
servingTrue if the service is serving
Returns
Success or error

Definition at line 782 of file service_registry.cpp.

784{
785 return impl_->set_service_health(service_name, serving);
786}
auto set_service_health(const std::string &service_name, bool serving) -> VoidResult

References kcenon::network::protocols::grpc::serving.

◆ unregister_service()

auto kcenon::network::protocols::grpc::service_registry::unregister_service ( const std::string & service_name) -> VoidResult

Unregister a service.

Parameters
service_nameFull service name
Returns
Success or error

Definition at line 731 of file service_registry.cpp.

732{
733 return impl_->unregister_service(service_name);
734}
auto unregister_service(const std::string &service_name) -> VoidResult

Member Data Documentation

◆ impl_

std::unique_ptr<impl> kcenon::network::protocols::grpc::service_registry::impl_
private

Definition at line 552 of file service_registry.h.

Referenced by is_reflection_enabled(), service_names(), and services().


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