mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 08:20:02 +02:00
updates Server docstring
This commit is contained in:
parent
36a8e916f6
commit
bb4de988e9
@ -78,75 +78,73 @@ class Server:
|
|||||||
"""
|
"""
|
||||||
The `Server` class provides a flexible server implementation for the `DataService`.
|
The `Server` class provides a flexible server implementation for the `DataService`.
|
||||||
|
|
||||||
Parameters:
|
Args:
|
||||||
-----------
|
service: DataService
|
||||||
service: DataService
|
The DataService instance that this server will manage.
|
||||||
The DataService instance that this server will manage.
|
host: str
|
||||||
host: str
|
The host address for the server. Default is '0.0.0.0', which means all
|
||||||
The host address for the server. Default is '0.0.0.0', which means all available
|
available network interfaces.
|
||||||
network interfaces.
|
rpc_port: int
|
||||||
rpc_port: int
|
The port number for the RPC server. Default is 18871.
|
||||||
The port number for the RPC server. Default is 18871.
|
web_port: int
|
||||||
web_port: int
|
The port number for the web server. Default is 8001.
|
||||||
The port number for the web server. Default is 8001.
|
enable_rpc: bool
|
||||||
enable_rpc: bool
|
Whether to enable the RPC server. Default is True.
|
||||||
Whether to enable the RPC server. Default is True.
|
enable_web: bool
|
||||||
enable_web: bool
|
Whether to enable the web server. Default is True.
|
||||||
Whether to enable the web server. Default is True.
|
filename: str | Path | None
|
||||||
filename: str | Path | None
|
Filename of the file managing the service state persistence. Defaults to None.
|
||||||
Filename of the file managing the service state persistence. Defaults to None.
|
use_forking_server: bool
|
||||||
use_forking_server: bool
|
Whether to use ForkingServer for multiprocessing. Default is False.
|
||||||
Whether to use ForkingServer for multiprocessing. Default is False.
|
additional_servers : list[AdditionalServer]
|
||||||
additional_servers : list[AdditionalServer]
|
A list of additional servers to run alongside the main server. Each entry in
|
||||||
A list of additional servers to run alongside the main server. Each entry in the
|
the list should be a dictionary with the following structure:
|
||||||
list should be a dictionary with the following structure:
|
- server: A class that adheres to the AdditionalServerProtocol. This class
|
||||||
|
should have an `__init__` method that accepts the DataService instance,
|
||||||
|
port, host, and optional keyword arguments, and a `serve` method that is
|
||||||
|
a coroutine responsible for starting the server.
|
||||||
|
- port: The port on which the additional server will be running.
|
||||||
|
- kwargs: A dictionary containing additional keyword arguments that will be
|
||||||
|
passed to the server's `__init__` method.
|
||||||
|
|
||||||
- server: A class that adheres to the AdditionalServerProtocol. This class
|
Here's an example of how you might define an additional server:
|
||||||
should have an `__init__` method that accepts the DataService instance,
|
|
||||||
port, host, and optional keyword arguments, and a `serve` method that is a
|
|
||||||
coroutine responsible for starting the server.
|
|
||||||
- port: The port on which the additional server will be running.
|
|
||||||
- kwargs: A dictionary containing additional keyword arguments that will be
|
|
||||||
passed to the server's `__init__` method.
|
|
||||||
|
|
||||||
Here's an example of how you might define an additional server:
|
|
||||||
|
|
||||||
|
|
||||||
>>> class MyCustomServer:
|
>>> class MyCustomServer:
|
||||||
... def __init__(
|
... def __init__(
|
||||||
... self,
|
... self,
|
||||||
... service: DataService,
|
... data_service_observer: DataServiceObserver,
|
||||||
... port: int,
|
... host: str,
|
||||||
... host: str,
|
... port: int,
|
||||||
... state_manager: StateManager,
|
... **kwargs: Any,
|
||||||
... **kwargs: Any
|
... ) -> None:
|
||||||
... ):
|
... self.observer = data_service_observer
|
||||||
... self.service = service
|
... self.state_manager = self.observer.state_manager
|
||||||
... self.state_manager = state_manager
|
... self.service = self.state_manager.service
|
||||||
... self.port = port
|
... self.port = port
|
||||||
... self.host = host
|
... self.host = host
|
||||||
... # handle any additional arguments...
|
... # handle any additional arguments...
|
||||||
...
|
...
|
||||||
... async def serve(self):
|
... async def serve(self):
|
||||||
... # code to start the server...
|
... # code to start the server...
|
||||||
|
|
||||||
And here's how you might add it to the `additional_servers` list when creating a
|
And here's how you might add it to the `additional_servers` list when creating
|
||||||
`Server` instance:
|
a `Server` instance:
|
||||||
|
|
||||||
>>> server = Server(
|
>>> server = Server(
|
||||||
... service=my_data_service,
|
... service=my_data_service,
|
||||||
... additional_servers=[
|
... additional_servers=[
|
||||||
... {
|
... {
|
||||||
... "server": MyCustomServer,
|
... "server": MyCustomServer,
|
||||||
... "port": 12345,
|
... "port": 12345,
|
||||||
... "kwargs": {"some_arg": "some_value"}
|
... "kwargs": {"some_arg": "some_value"}
|
||||||
... }
|
... }
|
||||||
... ],
|
... ],
|
||||||
... )
|
... )
|
||||||
... server.run()
|
... server.run()
|
||||||
|
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
Additional keyword arguments.
|
Additional keyword arguments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__( # noqa: PLR0913
|
def __init__( # noqa: PLR0913
|
||||||
|
Loading…
x
Reference in New Issue
Block a user