Class ServiceClientProxyManager
Defined in File service_client_proxy_manager.hpp
Inheritance Relationships
Base Type
public std::enable_shared_from_this< ServiceClientProxyManager >
Class Documentation
-
class ServiceClientProxyManager : public std::enable_shared_from_this<ServiceClientProxyManager>
Managing all service client proxies.
This class is responsible for managing all created service client proxies. Whenever a real service server is detected to have started, the corresponding service client proxy will be created to connect to this service server.
Public Types
-
using ClientProxy = rclcpp::GenericClient
-
using ClientProxyChangeCallbackType = std::function<bool(SharedClientProxy&)>
Public Functions
-
~ServiceClientProxyManager()
-
void set_client_proxy_change_callback(ClientProxyChangeCallbackType func_add, ClientProxyChangeCallbackType func_remove)
Set the callback function to be called when a load balancing service is added or removed.
- Parameters:
func_add – A callback for adding a new load balancing service server
func_remove – A callback for removing a load balancing service server
Send a request to the load balancing service server using the specified service client proxy.
- Parameters:
client_proxy – Specified service client proxy
request – Untyped request message
sequence – Output sequence number of sending request
- Returns:
True if sending successfully, otherwise False.
-
SharedClientProxy create_service_proxy(const std::string service_name)
Create generic client to specified service name.
- Parameters:
service_name – service name to be connected by created generic client
- Returns:
A shared pointer to GenericClient.
-
void start_discovery_service_servers_thread()
Start a thread to periodically discover new load balancing service servers.
-
void stop_discovery_thread_running(void)
Set a flag to terminate discovery service servers thread.
-
bool is_discovery_thread_running(void)
Check if discovery service servers thread is launched.
-
void remove_load_balancing_service(const std::string &new_services)
Remove a record of service server name and its corresponding service client proxy. These records are maintained by the ServiceClientProxyManager itself.
- Parameters:
new_services – load balancing service name to be removed.
-
void send_request_to_check_service_servers()
Activate a discovery operation once in the discovery thread.
-
SharedClientProxy get_created_client_proxy(const std::string &service_name)
Return the corresponding service client proxy based on the load balancing service name.
- Parameters:
service_name – load balancing service name
- Returns:
service client proxy if found, otherwise nullptr
-
using ClientProxy = rclcpp::GenericClient