|
| __init__ (self, str name, Type req_type, Type resp_type, Callable[[str, object], object] callback, str registry_host, int registry_port, str host=None, int port=None, is_default=False) |
| Initialize the service.
|
| register_with_registry (self) |
| Register the service with the registry server.
|
| __repr__ (self) |
| restart (self) |
| Restart the service communication handlers.
|
| suspend (self) |
| Shut down the service and deregister from the registry.
|
bool | deregister_from_registry (self) |
| Deregister the service from the registry server and validate the response.
|
| get_info (self) |
| Return a dictionary describing this service instance.
|
Public Member Functions inherited from comm_handler.comm_handler.CommHandler |
| __init__ (self, LCM lcm, str channel_name, type channel_type) |
| Initializes the communication handler with an LCM instance, a channel name, and a channel type.
|
str | __repr__ (self) |
| Returns a string representation of the communication handler, showing the channel name and the type of message it handles.
|
|
str | _get_local_ip (self) |
| Get the local IP address of the machine.
|
int | _find_free_port (self) |
| Find a free port to bind the service.
|
| _serve (self) |
| Serve incoming service requests.
|
| _recvall (self, conn, n) |
| Helper function to receive n bytes from a socket.
|
◆ __init__()
comm_handler.service.Service.__init__ |
( |
| self, |
|
|
str | name, |
|
|
Type | req_type, |
|
|
Type | resp_type, |
|
|
Callable[[str, object], object] | callback, |
|
|
str | registry_host, |
|
|
int | registry_port, |
|
|
str | host = None, |
|
|
int | port = None, |
|
|
| is_default = False ) |
Initialize the service.
- Parameters
-
name | Name of the service. |
req_type | Request message class with encode/decode. |
resp_type | Response message class with encode/decode. |
callback | Callback handling the request. |
registry_host | Registry server host. |
registry_port | Registry server port. |
host | Optional host to bind the service. |
port | Optional port to bind the service. |
◆ __repr__()
comm_handler.service.Service.__repr__ |
( |
| self | ) |
|
Returns a string representation of the communication handler, including
the channel name and the types of messages it handles.
The string is formatted as:
"channel_name[request_type, response_type]".
@return: A string representation of the handler, formatted as
"channel_name[request_type,response_type]".
◆ _find_free_port()
int comm_handler.service.Service._find_free_port |
( |
| self | ) |
|
|
protected |
Find a free port to bind the service.
- Returns
- : Available port number.
◆ _get_local_ip()
str comm_handler.service.Service._get_local_ip |
( |
| self | ) |
|
|
protected |
Get the local IP address of the machine.
- Returns
- : Detected local IP address.
◆ _recvall()
comm_handler.service.Service._recvall |
( |
| self, |
|
|
| conn, |
|
|
| n ) |
|
protected |
Helper function to receive n bytes from a socket.
- Parameters
-
conn | Socket connection. |
n | Number of bytes to read. |
- Returns
- : Received bytes or None on EOF.
◆ _serve()
comm_handler.service.Service._serve |
( |
| self | ) |
|
|
protected |
Serve incoming service requests.
◆ deregister_from_registry()
bool comm_handler.service.Service.deregister_from_registry |
( |
| self | ) |
|
Deregister the service from the registry server and validate the response.
- Returns
- : True if deregistration succeeded.
◆ get_info()
comm_handler.service.Service.get_info |
( |
| self | ) |
|
◆ register_with_registry()
comm_handler.service.Service.register_with_registry |
( |
| self | ) |
|
Register the service with the registry server.
- Returns
- : True on success, False otherwise.
◆ restart()
comm_handler.service.Service.restart |
( |
| self | ) |
|
◆ suspend()
comm_handler.service.Service.suspend |
( |
| self | ) |
|
◆ _stop_event
comm_handler.service.Service._stop_event = threading.Event() |
|
protected |
◆ callback
comm_handler.service.Service.callback = callback |
◆ comm_type
str comm_handler.service.Service.comm_type = "Service" |
◆ host
comm_handler.service.Service.host = host if host is not None else self._get_local_ip() |
◆ is_default_service
comm_handler.service.Service.is_default_service = is_default |
◆ port
comm_handler.service.Service.port = port if port is not None else self._find_free_port() |
◆ registered
comm_handler.service.Service.registered = self.register_with_registry() |
◆ registry_host
comm_handler.service.Service.registry_host = registry_host |
◆ registry_port
comm_handler.service.Service.registry_port = registry_port |
◆ req_type
comm_handler.service.Service.req_type = req_type |
◆ resp_type
comm_handler.service.Service.resp_type = resp_type |
◆ service_name
comm_handler.service.Service.service_name = name |
◆ thread
comm_handler.service.Service.thread = threading.Thread(target=self._serve) |
The documentation for this class was generated from the following file: